Scegliere un framework php, confronto tra il framework kohana php e codeigniter.
Ogni programmatore che si rispetti, che vuole rimanere competitivo sul mercato, è sempre alla continua ricerca di qualche libreria/framework che gli permetta di semplificare il proprio lavoro, ovvero: ridurre i tempi di sviluppo, migliorare sempre le proprie applicazioni, ottenenere risultati ottimi avvalendosi di strumenti efficienti, senza dover ogni volta “reinventare la ruota” ecc.
Esistono per questo framework, insiemi di librerie e di classi dall’utilizzo più o meno standard, che ci permettono di programmare in modo più semplice, estendendo l’esistente, senza doverci preoccupare direttamente di alcune problematiche: ad esempio dell’interfacciamento al database o dell’implementazione della sicurezza o di altri dettagli implementativi che allungano notevolmente i tempi di sviluppo, aumentano la complessibilità, diminuendo la gestibilità complessiva, e facendoci perdere sostanzialmente denaro.
Purtroppo o per fortuna, esistono tantissimi framework, e sicuramente fare la “scelta giusta” (eliminando le tempistiche di provare e imparare strumenti inadeguati ai nostri scopi) non è sicuramente banale.
Leggendo questo articolo di Fred Wu, mi sono reso conto che ho ripercorso la stessa strada durante la scelta del mio strumento di programmazione, quindi voglio riportare più o meno le medesime considerazioni che mettono in comparazione il framework che attualmente stò utilizzando (Codeigniter) e il suo “rivale”, il fork kohana php che potrebbe sostanzialmente riampiazzarlo.
Inizialmente il primo framework che ho provato è stato CakePHP, al tempo la documentazione era praticamente inesistente e sicuramente utilizzare un framework senza documentazione è da autolesionisti, perchè comporta sicuramente molto più studio personale, quindi ho cercato subito un’alternativa più accessibile.
Ho fatto diverse ricerche, ero orientato su due framework, il famosissimo Zend e Codeigniter, ma alla fine ho optato per CodeIgniter. Soprattutto per la splendida documentazione online (in inglese). Infatti la documentazione di Codeigniter è veramente impressionante, nel senso buono: completa, molto chiara e ben corredata di esempi; per un programmatore che conosce i linguaggi ad oggetti e php, basta un piccola letta per iniziare subito a sviluppare e creare in tempi brevi applicazioni molto potenti.
CodeIgniter è un framework che ha avuto in questi tempi ottimi progressi e ha guadagnato la fiducia di molti sviluppatori web, anche se tempo fa aveva rallentato la sua corsa perchè gli sviluppatori erano quasi tutti concentrati sulla nuova versione di ExpressionEngine CMS. Infatti alcuni degli assidui utilizzatori sul forum di Codeigniter erano molto frustrati, perché segnalavano bug e richieste di nuove funzionalità, ma venivano quasi sempre ignorati, o rimanevano in attesa dei mesi. Questo chiaramente, fece si che gli sviluppatori interessati realmente all’avanzamento del progetto, decisero di far nascere il fork BlueFlame, più tardi rinominato in Kohana, e di iniziare uno sviluppo parallello prendendo alcune decisioni tecniche diverse.
Kohana è un framework php praticamente sconosciuto al grande pubblico. Infatti, la maggior parte degli utenti Kohana sono ex utilizzatori di Codeigniter o utenti che usano entrambi a seconda delle necessità. Secondo Wikipedia, le differenze tra Kohana e CodeIgniter sono:
Come si può vedere da questa lista, pur mantenendo un certo grado di somiglianza con CodeIgniter, Kohana offre alcuni vantaggi (al tempo stesso, alcuni svantaggi, dipende dai punti di vista). Per fare ulteriore chiarezza diamo un’occhiata alla tabella sottostante, che non ho volutamente tradotto, perchè già molto chiara e schematica. Chiaramente per la valutazione verranno considerate solo le funzionalità disponibili nei pacchetti ufficiali, non quelle integrabili attraverso estensioni di terze parti.
| Feature | CodeIgniter 1.6.1 | Kohana 2.1.1 | Notes |
|---|---|---|---|
| License | Apache/BSD-style | new BSD | Licenses are similar, although Kohana uses the new BSD license which is slightly more flexible than CI’s modified BSD license. |
| PHP compatibility | 4.3.2+ and 5 | 5.1.3+ | CodeIgniter supports PHP4 whilst Kohana is a stict PHP5 framework. If you are using PHP5 then Kohana offers more OOP and performance advantages. Start from version 2.2 (yet to be released), Kohana will only support PHP 5.2+. |
| Supported Databases | MySQL (4.1+) MySQLi MS SQL PostgreSQL SQLite Oracle ODBC |
MySQL PostgreSQL SQLite |
CodeIgniter’s longer history ensures us a more widely available database support options than Kohana, although in the future Kohana is likely to support more databases too. |
| Community | Forum Wiki Bug Tracker |
Forum Trac IRC |
CodeIgniter obviously has a much larger community and offers a wiki for community members to share tutorials and code snippets. Kohana on the other hand, has a smaller community, however the developers are actively online on the forum and IRC. |
| Documentation / User Guide | Excellent | Limited | CodeIgniter is known for its excellent user guide. Kohana is in the process of improving its documentation. |
| Tutorial / Sample Availability | Good | Fair | Tutorials are available on both of their forums. CodeIgniter has the advantage of having a wiki for easier navigation. Kohana on the other hand, has a dedicated tutorial page for some of the tutorials. |
| MVC | Strict | Strict | Both frameworks use the same MVC approach. |
| Modular / HMVC | Via 3rd party libraries | Built in | Kohana is built with HMVC in mind whilst CodeIgniter has some 3rd party libraries such as Matchbox and Modular HMVC to accomplish the same effect. |
| Conventions | Flexible | Flexible | Unlike CakePHP, both of the frameworks offer flexible convensions. There are some defaults but most of them can be overwritten. |
| Configuration | PHP files | PHP files | In my opinion Kohana is more configurable than CodeIgniter yet it is simpler (less clustered) to do so! Most of the Kohana configuration files are stored in the system folder, you only copy and paste the ones you actually need to modify, and modify them accordingly. CodeIgniter’s config files are all stored in the application folder. |
| Database Abstraction | Modified ActiveRecord | Modified ActiveRecord ORM (optional) |
Both frameworks use the modified ActiveRecord pattern. Kohana has an optional ORM module. CodeIgniter has some ORM and Rails-style ActiveRecord implementation avaliable via 3rd party libraries. |
| ACL | Via 3rd party libraries | Auth library (optional) | Neither of the frameworks forces you to use a specific ACL mechanism. CodeIgniter does not have one built in, and Kohana has one available as an optional module. |
| Validation | Good | Good | Both frameworks offer a good built in validtion layer. Kohana 2.2 is planned to have some significant improvements for the validation library. |
| Caching | Limited | Fair | In my opinion both of the caching features are limited. Kohana offers a slightly more useful cache library that supports file, SQLite, APC, eAccelerator, memcache, and Xcache based caching, with tag support. |
| Session | Good | Excellent | CodeIgniter 1.6 has improved its session library, but it’s still inferior to Kohana’s implementation. Kohana’s session library supports both encryption and storing session data in database. |
| Logging / Debugging | Good | Excellent | Both frameworks offer very good logging and debugging mechanisms. Kohana is a little bit ahead thanks to PHP5’s native Exception class and its powerful event handlers. |
| Templating | Native PHP | Native PHP | Templating is *very* easy for both frameworks. If you can skin Wordpress, then you’d have no problems at all skinning CI or Kohana. If you want though, you can still incorporate one of the 3rd party templating solutions such as Smarty. |
| Helpers | Good | Good | Helpers are usually libraries that used for simple, repetitive tasks. Both frameworks offer a wide range of helpers for handling forms, URLs and dates, etc. |
| JavaScript / AJAX | N/A | N/A | Both frameworks respect your choice of JavaScript / AJAX frameworks. Unlike CakePHP and Ruby on Rails, they don’t have built-in helpers for any of the JavaScript libraries. This offers more flexibility as well as the use of unobtrusive JavaScript. |
| Web Services | Fair | Fair | I could be wrong but I don’t think either framework supports (or at least encourages) RESTful design… |
| Localization | Limited | Good | CodeIgniter has limited i18n support whilst Kohana offers a bit more (timezone / full UTF8 layer, etc). |
| Unit Testing | Limited | None * | CodeIgniter’s built in unit testing class is very limited. * Kohana as of version 2.1.1 does not have a unit testing class, however it is planned for version 2.2. |
E’ molto difficile decidere quale dei due framework utilizzare, entrambi hanno caratterstiche molto simili e forse Kohana nel tempo potrebbe affermarsi per la sua flessibilità, ma sicuramente ha ancora bisogno di crescere e di completare i propri supporti e la propria documentazione. CodeIgniter è sicuramente ottimo, soprattutto se si ha la necessità di avere ancora la retro compatibilità sull’ormai morto PHP4, ricordando che sicuramente è il framework migliore dal punto di vista della documentazione e possiede un bacino di utenza più ampio da cui poter trarre spunti e confronti.
Riferimenti:
http://thislab.com
I framework sono molto utili !! permettono (e io che sono sviluppatore da anni posso dirlo) di risparmiare moltissimo tempo in fase di sviluppo !! dopo anni anche io mi sono deciso a svilupparne uno ! e nn posso fare altro che appoggiare chiunque sviluppi questo tipo di progetti.