Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Yes. Pretty much the entire point of this thread.
  2. Indeed. You talk about poor OOP practices and you mention procedural code. That's like writing an article about Italy and then go on describing the country-side in Australia. How call_user_func and if/switch fit into the poor OOP practices is also lost on me.
  3. There is no typical term. You can make this up. Some use pro account, others use premium account. If you have multiple levels in your premium accounts, you can use gold, silver, copper as differentiators.
  4. A dependency is when one thing requires another to work. For example: class A implements FrameworkSpecificInterface class A extends FrameworkClassB class A { public function setFoo(FrameworkSpecificInterface $i) } class A { const B = FrameworkFoo::B; }These are hard depencies on an interface, a class, a constant, and a soft depency on the framework it's from (if these were framework things). These are hard depencies since your code won't run if it can't find the class/interface/constant. Dependency injection/IoC does not remove these dependencies, they merely help you to bind these dependencies dynamically. It also allows you to decouple any using code from having to know how to construct the object. That said, IoC is not a new concept, in fact there are many patterns you may already know that provide IoC: a Factory, a Facade, a Builder. These all share the same thing they hide the construction of an object from the code that uses it, though less dynamically then a dependency injection container. http://en.wikipedia.org/wiki/Inversion_of_control
  5. Portfolio. Is sufficient to have your foot in the door. Most employers will also use a technical test to ascertain quality offered. For example we use multiple empirical technical tests which basically acts as a grading system. Candidates that passed are contacted for a conversation.
  6. http://forums.phpfreaks.com/topic/281633-generate-a-registration-id-and-display-it-after-successful-registration/?do=findComment&comment=1447128
  7. Our first hindu in the Guru rank.
  8. Your MVC implementation is wrong. class Controller { private $view; private $model; } class Model { } class View { private $model; }Your controller connects your Model and View. Not your View.
  9. I think it's great to see two people decide to repeat what I said.
  10. table (.., version) table_versions (.., version)In table version is default 1 when you update the row you copy it to the *_versions table. You update the table, and increment the version on the 'table' table. You might wanna lock the row/table before doing this to avoid multiple people overriding each others changes.
  11. If you use Doctrine you can create your database schema in code. Schema updates can then be performed through code.
  12. Double post http://forums.phpfreaks.com/topic/281490-systemportal-to-manage-logins-authenticate-other-systems-basic-functions/?do=findComment&comment=1446430
  13. Your website is flagged by my antivirus as harmful. http://browsingprotection.f-secure.com/swp/result?url=http%3A%2F%2Fuqload.com%2F
  14. The result you return is passed to the success function. success: function(data) { var el = document.getElementById('subcategory_id'); $(el).empty(); // remove all HTML inside <select/> $.each(data, function(i, option) { // add each <option/> from data $('<option value="' + option.id + '">' + option.name + '</option>').appendTo(el); }); }
  15. Dupe: http://forums.phpfreaks.com/topic/281199-php-assigne/
  16. It's easier to install phpunit and zendframework through composer. Download composer.phar and put it inside your project directory. Then using the commandline type: $ composer.phar require phpunit/phpunit zendframework/zendframework
  17. No. It was the answer to your second question. A front controller is the single point of entry to boot your application, in Java this is your main method. In C++ this is main(). In PHP this is index.php (or whatever you set as default). Since files can easily be served by Apache you don't need a front controller as Apache does all your front controller needs. However where your system consists of functions or objects it's not so easy to route a request to an object which is why you use a front controller to do this for you. Thus translating /foo/bar to (new Foo)->bar() or to foo_bar().
  18. If all your controllers are named: index.php, start.php, .. then you don't need a front controller as Apache already does all what your front controller would do. The reason there is a front controller in some systems is because something has to translate /foo/bar to (new Foo)->bar(); or foo_bar(); when your controllers however are files, then your front controller is obsolete. Using includes you would center the logic required to redirect the user to the correct page, like when he is not logged in.
  19. You understood me wrong in your controller you can use this however you want, but not inside your update_save function. You can pass these like so: update_save($_POST['foo'], $_POST['bar']);If you need a redirect you just add it: update_save(..); header('Location: ..'); exit;
  20. Yes. It separates the 3 responsibilities. Though a controller should not execute queries as only your model should be capable to do this. Also your update_save function should receive it's data from the controller and not use $_POST or $_GET internally since only your controller knows about $_POST and $_GET. The controller should be a firewall of some sort, between the client and your controller HTTP exists, but the model should be agnostic of HTTP. HTTP CALLS { client }<---->{ controller}---->{ model } The advantage here is that you can change HTTP to for example CLI or SOAP or whatever without having to change the underlying model. Since $_POST, $_GET, $_COOKIE, $_SESSION are part of HTTP it's therefor that your model should be agnostic of these variables. A model should not issue redirects since redirect's are the responsibility of the controller.
  21. A template and a view are the same thing. In MVC the View is the part of the application that displays the results of a user's action and the application's processing. How you make up that View is entirely up to you. MVC is an idea and thus not bound to any technical implementation's, the same applies to views. For example: // the file is the controller (binds model and view) if ($_POST) { // mail is part of our model mail('[email protected]', $_POST['subject'], $_POST['message']); // thank-you.html is part of our views include 'thank-you.html'; exit; } // contact.html is part of our views include 'contact.html'; // all concerns have been separatedThis is an MVC implementation.
  22. When posting code, mind that this is a public forum. And any sensitive data is for the world to see. I removed your db credentials, but I advice you to change them.
  23. MUAHAHA! MORE MINIONS! MORE MINIONS!!! uhm.. I meant congrats on the promotion.
  24. Don't use inheritance. Test is not a Common. Instead pass it through the constructor or a setter. class Test { private $common; public function __construct(Common $common) { $common->initSomething(); } }
×
×
  • 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.