Jump to content

sunwukung

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by sunwukung

  1. the value of using a pre-built framework a) common standard that can be shared between developers b) code you write can be picked up easier by subsequent developers c) documentation is better d) good quality components already available e) component have been tested in superior number of projects f) access to community with common knowledge g) learn a great deal about application architecture by studying someone else's work disadvantages: a) learning curve b) can be rather bloated for task at hand c) different frameworks excel at different types of application - but you won't know that until you've used them for a while d) can be tricky to implement AJAX functionality at first pass The only real value in writing your own is that a) you learn a lot from doing so b) the framework you write may be a lot more lightweight since it is custom built for your way of working c) it does something that no other framework does However, as your homebrew gets bigger, you will find yourself maintaining that code over time too.
  2. IME, while Magento has a lot of nice features, it's pretty hard work - and it DEVOURS resources. That's why you get Magento specialist hosting. Personally, I'd give Magento a miss and go for a different cart system - probably commercial for the sake of customer support.
  3. The choice will come down to the project requirements. Get a list of all the functionality, check if the CMS supports (or has plugins that support) all the requirements. If you get 80-90% yes, use an off the shelf CMS. If not, build bespoke (for considerable increase in cost).
  4. Dreamweaver is a poor IDE for coding PHP, Netbeans or Eclipse are far better. PhpDesigner isn't bad either. Here's my 2 pence review CodeIgniter: easy to learn, but based on PHP4. May lack power for more complex jobs. Great documentation - best starting point for beginner. Kohana: basically an OOP/PHP5 version of CodeIgniter, with less documentation. CakePHP: forces convention over configuration. What that means is that it offers you one way to skin a cat so you don't get confused. Zend: The antithesis of Cake - you can configure this all over the place, and it can be very confusing. Documentation can sometimes be confusing. Symfony: uses a lot of configuration again, but is recognised by the enterprise community.
  5. You won't stop using "core" php simply because you use a framework - it's not quite as abstracted as a JS lib like jQuery. You'll still get your hands pretty dirty in the logic/model layers of any application. It should just take the pain out of some fairly standard tasks - view management, database connections, form validation. You may find that you're only really using the MVC setup, and the rest is raw code.
  6. Not so fast! It really depends on the usage/application design. You could make a single "cart" object, and each item the user picks then becomes a property of the cart. That might take the form of a discrete property for each item, or alternatively part of an associative array which can be used as a reference point from which you can pull up product data if the user wishes to review their purchases later. You can then persist the object in medium X (a database would allow you to keep the cart data on hand for the next time the user logs in). On the other hand, it may be overkill if that's ALL the cart does, since that will reduce the object to little more than an expensive associative array. You may, however, think of additional functionality to append to the cart which can then be brought to bear on the cart contents, like sorting, adding, removing, changing quantities etc... Try to think of the "cart" as representing an object in the real world - what would it do? This is fundamental to the concept of the Domain Model, a conceptual model of a given business domain. Since all data can be represented as arrays, why use objects at all? I'd recommend reading up on Domain Modelling, it will help bridge the gap from OOP theory to practice: http://www.infoq.com/minibooks/domain-driven-design-quickly
  7. I've just figured it out. The calling class (Application) should be given responsibility for executing runConfig - not the Config class...DOH! I knew something was smelling... thanks for replying
  8. No offense, but are the images you're loading png's/gifs etc? Can you provide us with some of the error messages? It might be any number of reasons - file size is too large, image wasn't copied to location x...
  9. I wanted to know if there was a way to prevent a method in a class being called unless it is called by a specific (non-inheritance chain) object. I'm borrowing from the Zend Bootstrapping pattern: class abstract Config_Abstract(){ public function runConfig(){ //iterate over methods declared in child and execute each in turn } } class Config extends Config_Abstract(){ publc function initGood(){ //do some stuff } publc function initBad(){ $this->runConfig(){//VERY BAD - CIRCULAR CODE } } } class Application(){ public function run(){ $Config = new Config(); $Config->runConfig();//should only be executed by Application class } } $App = new App(); $App->run(); there are two methods I've thought of so far, but I wanted to know if Reflection or magic methods had something that could deal with this 1: use debug_backtrace() to detect the calling object 2: pass in a reference to the calling object in the configRun() argument Can anyone offer some insight?
  10. Doh! I see it now...I had assumed that because the page was refreshed, that it would send back the data from the host - but obviously that part of the page isn't executed on the host until after the update... I feel like a spanner now!
  11. I am writing an application to CRUD user details. I kick off the page with a query to the user table - and use the data to populate various form elements in the page (and to check for duplicates). All form submissions submit to the same page. Adding, deleting and modifying records work as expected - but the kicker is that the data *displayed* on the page does not update accordingly once a change is submitted - I have to revisit the page in order to see the relevant changes. try{ $user_sql = "SELECT user_ID, user_firstname,user_surname,user_email,user_type FROM users"; $user_stmt = $db->prepare($user_sql); $user_stmt->execute(); $user_data = $user_stmt->fetchAll(PDO::FETCH_NAMED); $i++; }catch(PDOException $e){ echo "Error: cannot retrieve user data from the data base"; } /* * DELETE USER */ if(isset($_POST['deleteUser'])){ $_SESSION['deleteUser']=true; } if(isset($_POST['submitDeleteUserConfirm'])){ //process query if($_POST['deleteUserConfirm']=='yes'){ $deleteRange=implode(',',$_POST['deleteUser']); $deleteSql = 'DELETE FROM users WHERE ID_users IN (' . $deleteRange . ')'; try{$q = $db->prepare($deleteSql); $q->execute(); } catch(PDOException $e){ echo '<p>System Error: '. $e->getMessage() .'</p>'; } } //once confirmation has been processed: //remove session trigger to hide confirmation form if(isset($_SESSION['deleteUser'])){ unset($_SESSION['deleteUser']); } } if(isset($_SESSION['deleteUser'])){ ?> <fieldset class="radiobox"> <legend>Confirm</legend> <div> <label for="deleteUserYes">Yes</label> <input type="radio" class="radio" name="deleteUserConfirm" id="deleteUserYes" value="yes"> </div> <div> <label for="deleteUserNo">No</label> <input type="radio" class="radio" name="deleteUserConfirm" id="deleteUserNo" value="no" checked> </div> <input type="submit" name="submitDeleteUserConfirm" value="Confirm"> </fieldset> <?php } //small function to output all the elements of an array as checkboxes $delStudentRollOpts = array( 'key'=>'users', 'sticky'=>true, 'data'=>array( 'values'=>$user_data,# USES DATA FROM START OF SCRIPT - NOT UPDATING ON PAGE REFRESH/FORM SUBMISSION 'name'=>array('user_firstname','user_surname') ), 'element_name'=>'delStudRoll_'.$n, 'types'=>array('checkbox'=>array('title'=>' ', 'name'=>'deleteUser', 'index'=>'ID_users' )) ); echo $GA_form->generateRoll($delStudentRollOpts); echo '<input type="submit" class="submit" name="submitDeleteUser_'.$n.'" value="Delete">'; echo '</fieldset>'; echo '</form>'; This is very much a work in progress, so it needs a lot of refactoring... From the user's perspective: 1: enter new data 2: submit form 3: check db from MySQL console - new data inserted 4: no new data shown 5: visit page again - new data appears (refreshing will trigger an error trying to re-submit duplicate values) Anyone have any ideas what's happening? At the moment I'm toying with the idea of redirecting back to the page with a header...
  12. Sorry - I should add that I've omitted this part of the code for the sake of brevity: public static function getInstance(){ if( !isset( self::$instance ) ){ self::$instance = new self(); } return self::$instance; } Which allows you to access it's methods.
  13. Hi, I've been trying to write an error handling class that I can use on sites, that will email me in the event of an error. Problem is, when I profile the application, it's choking on the error_log function. Here's my code (omitting the class: class ErrorHandler { private static $instance; private static $mail; private function __clone(){} private function __construct() { error_reporting( E_ALL | E_STRICT ); if(!defined('ENV')){ if($_SERVER['SERVER_ADDR']=='127.0.0.1' || $_SERVER['SERVER_NAME']=='localhost') { #echo"local environment<br>"; DEFINE('ENV','LOCAL'); ini_set('display_errors', 1); } else { #echo"live environment"; DEFINE('ENV','LIVE'); ini_set('display_errors', 0); } } } public function setErrorConfig($error_level,$mail='',$mode='production') { error_reporting($error_level); switch($mode) { case 'development': ini_set('display_errors', '1'); break; case 'production': ini_set('display_errors', '0'); if($mail != ''){ self::$mail = $mail; set_error_handler(array('ErrorHandler', 'handleError')); } break; default: ini_set('display_errors', '0'); error_reporting( E_ERROR ); break; } } public function handleError($e_num,$e_msg,$e_file,$e_line,$e_vars) { $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: DC_Research Site' . "\r\n"; $msg = ''; $msg .= '<html><head></head><body>'; $msg .= '<STYLE>h2{font-family:verdana;}</STYLE>'; $msg .= '<h2>Error Description:</h2>'; $msg .= '<h2>Script:</h2><p>'.$e_file.'</p>'; $msg .= '<h2>Line:</h2><p>'.$e_line.'</p>'; $msg .= '<h2>Message:</h2><p>'.$e_msg.'</p>'; $msg .= '<h2>Variables:</h2><p>'.$e_vars.'</p>'; $msg .= '</html></body>'; #mail(self::$mail,'Error Report',$msg,$headers); error_log($msg,1,self::$mail,$headers); } } Can you help me figure out what's killing it?
  14. Hi all, this is not so much a technical problem as a design choice. We're having a discussion at work to consolidate disparate coding methods. In general, the PEAR and Zend standards documentation has provided suitable material for defining common practice goals. However, I wanted to ask your opinion about function declarations: Q: Should you declare functions for code that is only used once on a given page request? My feeling is that this is an incorrect use of functions, incurs an unnecessary (perhaps negligible) overhead. I guess you could also ask a similair question about objects - i.e: Q: At what point is a body of code eligible/ineligible for object construction? What are your thoughts?
  15. you'd think eh? I've been trying that <snip> I was using E_STRICT as my test case - using constants works fine... cheers for the help
  16. Hi folks I'm playing around with some custom error handling routines, which I've wrapped in a utility class. The constructor determines if the script is executing local/live and changes the error display parameters accordingly. I've created a setter method i.e: $obj->setErrorMode($level,$log); The first argument is the reporting level, the second is an optional log file. My problem is that if I try and pass anything other than the integer label for the error_reporting level, be it a string or a constant, it stops the error reporting working. This in itself is not a massive problem, but makes the method a bit less user friendly. Can anyone shed any light or give me some ideas how I could make this work (regardless of the OOP applicability in this situation)?
  17. Thanks for your help, I've got the vhost working now and the framework is all set up. Now for the hard part....
  18. sure, I get that. I'm new to all this - so I'm just trying to setup ZF as an experiment. I'll try and configure a vhost next - thought not entirely sure how to go about it. Anyway - I've found the problem: http://www.icyphoenix.com/viewtopic.php?f=2&t=4935 WAMP has to have the rewrite module enabled or it chokes on local .htaccess. I've activated the module and public is now accessible.
  19. Nope, same problem. Not sure what the problem is, only that it seems to work if I remove the .htaccess file: SetEnv APPLICATION_ENV development RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] I'll try this on a different WAMP setup to see if it's just my current setup.
  20. Feel free - as long as you help me solve it! yup, you're telling me. Can't figure it out for the life of me. I work with WAMP on a daily basis, so I can't understand why it wouldn't show a folder - and all my other projects are functioning fine. Incidentally, @Daniel10, I unpacked your tarball into the same folder, and still no public folder. Anyway, here's some progress - I removed the htaccess file form within the public folder - it became visible, and now I've been able to access the framework. Soooo, it's something to do with the .htaccess I guess. Since neither vhosts or .htaccess are my strong suit, can you think of why this might be causing an issue?
  21. DocumentRoot "c:/wamp/www/" - if I modify it to "C:\wamp\www\Sites\study\Zend\quickstart\public" it still doesn't work. I'm going to try out the vhosts option, but this seems like quite an odd bug.
  22. to be fair, they were all unpacked to a single project folder when I executed "zf create project quickstart" from the cmd (as in the quickstart tutorial on Zend's site). So why is public not visible to localhost?
  23. Sounds to me like you've actually put application, library and tests within your public directory. do you mean wamp's www directory? Basically, I created the project within wamps www directory because (as I understand it) it needs to be in there to parse the PHP correctly. All the folders are in one location: C:\wamp\www\sites\study\Zend\quickstart :(application, library, public, tests) ZF is here - and reference via the include_path in php.ini C:\wamp\ZendFramework Is that problematic?
  24. BUMP! I'm having similiar problems (I have a WAMP setup). Working through their quickstart guide, I successfully created the project - but when I try to navigate to the project folder - all the folders are visible EXCEPT public. When I try to access this folder, I get an internal server error. Any ideas? example: [DIR] application/ [DIR] library/ [DIR] tests/ where's freaking public!?
  25. Doh!! Managed to solve this one - it's the header. The header uses Location:'http://domainname' - and by omitting the 'www' it is seen as a different/sub domain, thus generating a new session.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.