6 ms·
CI was built in the PHP4 days, and for that reason it has a lot of cruft left over. For example, there is no autoloader. Also, classes are loaded as singletons,
by renownedmedia 14y ago
CI was built in the PHP4 days, and for that reason it has a lot of cruft left over. For example, there is no autoloader. Also, classes are loaded as singletons, and are assigned to properties of the controller, which I put into the 'magic' category, and isn't compatible with IDE autocomplete features (I'm a VIM user, but it makes things easier for a lot of developers).
//CI Class Load Example:
$this->load->library('example');
$this->example->something();
//Raw PHP Class Load Example:
$this->example = new Example();
$this->example->something();
As you can see, the latter is a little more obvious about what is going on.
- citricsquid 14y agoI'm not comp sci educated, I'm all self taught so maybe "Autoload" has a real meaning outside of this context, but CI does have an autoloader... something that can autoload libraries and models? application/config/autoload.php
- rokhayakebe 14y agoVery good question. I am self taught as well, and have been using CI for about 2 years now. I can autoload libs and helpers. I would love to read his answer there. Also another question would be which frameworks is he currently using and what are its advantages.
- renownedmedia 14y agoI answered his questions directly; I'm not doing too much PHP development these days, it is mostly Node stuff.
- renownedmedia 14y agoPHP has the ability to run a function when attempting to load a class which doesn't yet exist, which can load a file from the filesystem and get the class into memory. The CI version of autoloading is a manually entered list of classes to be loaded (a little ironic actually :p).
- troels 14y agohttp://php.net/manual/en/language.oop5.autoload.php http://php.net/manual/en/language.oop5.autoload.php
- iends 14y agoWhat PHP framework would you use if you had to today? Kohana? Yii? Something else?
- renownedmedia 14y agoI started using Kohana after moving on from CI, but these days, I don't do as much PHP development. It's mostly Node.js development now. I did start rebuilding this in Kohana a few months ago with the intention of rebuilding it as a less panel-y looking interface, but ended up scrapping the project.
- chrismsnz 14y agoI'm not the OP but almost any PHP project these days has me reaching for Symfony 2[0] or her little brother Silex[1] paired with Doctrine 2[2]. [0]. http://symfony.com/ http://symfony.com/ [1]. http://silex.sensiolabs.org/ http://silex.sensiolabs.org/ [2]. http://www.doctrine-project.org/ http://www.doctrine-project.org/
- renownedmedia 14y agoSymfony is nice, Zend 2 is going to fix everything from ZF1 and is worth keeping an eye on as well. I've dabbled in Doctrine before, but the memory usage looked a little too high for the convenience it offered.
- lftl 14y agoOut of curiosity what are you doing in PHP where memory usage is an issue? PHP's standard life cycle, while having numerous disadvantages, avoids a lot of problems with memory usage. It's a rather different beat, but you might checkout Propel (http://propelorm.org http://propelorm.org) for a different take on a PHP ORM. It has a static build phase unlike Doctrine which turns some people off, but if you can get past that it's a rather nice ORM.
- renownedmedia 14y ago