With a fresh installation of ExpressionEngine on my dev server, I’m now ready to begin converting my Code Igniter controllers, models and views to ExpressionEngine.
I feel like such a newbie. Starting over sucks, but the long-term benefit will hopefully be worth the effort.
Anyway, I’ve read through the module tutorial and everything seems straightforward. I would like to continue using my data models (albeit with any necessary syntax changes.) Are there any potential gotchas and what’s the method for loading them?
Does anyone have any other words of wisdom when it comes to converting CI code to EE modules?
Thanks!
p.s. Why does the spell checker show “ExpressionEngine” as incorrectly spelled? Shameful. :red:
Quick follow-up.
After reading through the user manual and playing with some of the examples, I’ve decided to stick with Code Igniter after all.
Unfortunately the template and module system of ExpressionEngine just too structured for my needs. I can think of a million uses for ExpressionEngine, but not when developing a custom proprietary application. I was pre-warned about this, but I didn’t know for sure until after getting my hands dirty.
Anyway, thanks for everyone’s indulgence.
This really depends on exactly what you are trying to do. Even with Codeigniter you are using an application that has been built to a certain point. I think you might have to alter your thinking a little.
If you were to build a weblog, authorization, and other modules then you would be creating a structured system for yourself where you could run into the same issues. The more you build out your application the more noise there will be to contend with. I think at this point the difference between Codeigniter and EE is that you feel more comfortable with your own application. I feel the same way when I move from development in Codeigniter to EE. I feel lost in EE after working in an application I built myself. When you feel like you have lost so much control (but you really didn’t, you just don’t have the same knowledge of EE as you do with your own app) then the first reaction is to go back to your comfort zone (CodeIgniter.)
Here is something else to chew on. ExpressionEngine has many modules and features that could save you a ton of time in development. ExpressionEngine has also been a successful development platform for many coders. I am not sure I could say the same for my own custom application. I could build my application to have just a fraction of the functionality that ExpressionEngine has only to find out that in my first attempt I totally screwed up the ability to easily go forward with extending the code-base. I might then have to scrap my own code and start over armed with this new knowledge. So far I have only done that with like… EVERY attempt that I have made so far. 😉
Remember that with Codeigniter you are building on the coding experience of the developer (Rick.) He has many years building in PHP, has developed his own best practices and he delivered those best practices in CodeIgniter. We then gain some of that knowledge and experience right off the bat by using his system and following his guidelines. ExpressionEngine is the same thing except with a fully built CMS.
So the moral of this whole thing is that any fully built application is going to get more structured from that added functionality. Any fully built application is going to be a little less flexible than a framework. The choice for you is to use the “too structured system” that is EE or build your own “too structured system.” Again, you will save some time going the EE route but I certainly share your love for CodeIgniter.
Now lets take a look at your post…
Starting over sucks
I think this is the biggest issue you are having. As I mentioned earlier, going back to familiar territory is so much easier than attempting to develop things in EE but remember that EE is largely where Codeigniter was pulled from. If there is something that EE does not have you could also consider adding it.
I’m now ready to begin converting my Code Igniter controllers, models and views to ExpressionEngine.
ExpressionEngine is not an MVC framework so you will have to rethink how you develop things. Development in EE is mostly done through plugins, modules, and extensions. Both modules and plugins are classes that would contain your custom PHP and queries but plugins are much more simple. A module would often have a control panel interface and database tables. Extensions are like CI hooks and would change the inner workings of EE.
Views of course are going to be taken care of by EE templates. Controllers and models are going to be a bit more tricky. Keep in mind that much of the functionality that would go into running your CI driven site is already going to be built into EE. You already have methods to send output to your templates. You already have a blogging engine. You already have an email system. Any models, controllers and libraries you had in place to carry these tasks are not needed.
I suppose the real question here would be this. What is missing from EE that your own application can do? Because the base system is already in place you need to think in terms of specific features. Keep in mind that in CodeIgniter a model is nothing too special. A model is simply a class that is called a model because CI users made noise about CI not appearing to be a true MVC framework. If you wanted a model in EE you could do the same but your custom features are probably going to be built as modules. You could create your model class and call those methods just as you would in CI. Your “controller” methods and libraries would probably need to go into the module file. You would then call the module from your templates (view,)
Again, this just takes some difference in thinking. Does that make sense?
Hi John, thanks for your explanation of moving from CI to EE. I am also a former CodeIgniter developer trying to learn ExpressionEngine. I can see how views are taken care of by the EE templates. I can also see how models aren’t necessary.
However, I am having trouble figuring out what to use in place of a controller.
Any ideas on how I could implement url actions? For example, I would like to run some php code when the user clicks on a link.
Thanks!
Modules are somewhat the controllers (or can be) in EE, you can use a module to provide URL triggered PHP actions.
http://expressionengine.com/docs/development/tutorial.html#controller_function
You can use your URL’s much the same as you can in CodeIgniter. The link could go to a template which runs a module or plugin and then redirect or whatever. For example, I built a language switcher module. If there are two flags on the site, clicking one with take you to a template which sets the language preference with a cookie and then redirects you to the template you came from. All that is in the “switcher” template is the module tag.
I highly suggest that you go to the developer section of the user guide and take a look through the functions of each of the classes. In particular, the functions class has a lot of useful bits. I believe the redirect is part of the functions class. There is also a “tracker” cookie which holds the x number of templates a user has visited.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.