CakePHP to CodeIgniter conversion - php

I want to convert an application from CakePHP to Code Igniter. Has anyone tried to do this? With my CakePHP application almost all the coding has been done in the controller layer, with the models pretty much exactly as they come out of baking.

CakePHP is newer, more feature rich and heavier than Code Igniter (CI is designed to have a much smaller footprint) so you will most likely find yourself creating functionality in CI to match cake's.
CakePHP also handles some core capabilities differently than CI. For example, routing functionality is handled via a dedicated class rather than per controller as in CI (via _remap).
I have never seen a tool that helps to automate such a conversion as it's rarely, if ever, done.
Taking all that into account, I believe the best approach is to rebuild your application from the ground up, drawing on your existing code and database schema.

Related

Could one use Laravel just for the login/authentication system?

Is it possible to use Laravel alongside another php application not built with a framework just for the login/authentication system?
Looking at other posts, I realize that's not the point of php frameworks, but my thought was for maximum security, using a framework would be best.
It's entirely feasible, yes. Especially if said application was properly classed and namespaced.
If it's not classed / namespaced, that rules out simply including it in Laravel. That'd likely be way more headache than it's worth.
In terms of security, there are a lot of routes you can go. In fact, there are authentication websites that take user information completely off of your hands. It may be worth looking into them.
The easiest solution would be to either find a class or library that is dedicated to authentication, and simply include it in your application (example here: http://ulogin.sourceforge.net/ or simply search for PHP Authentication Library). They're framework agnostic, and will be very simple to integrate into your project.
The bottom line is, you probably want something that's agnostic to frameworks / coding architectures. That'll be the easiest to integrate into a custom project.

Are there any limits in using a PHP framework?

I'm planning to use a PHP framework (Yii) for my future project due to the amount of features that it would contain. I have done a few PHP projects in the past and I now realize how disorganized they can get after a while, even if you use a proper directory structure. So, basically, I'm wondering if everything in PHP, can also be done in a framework without tweaking the core framework itself. Will there be any limits? Can I use PHP classes like geolocation, phpexcel or phpthumb: http://phpthumb.gxdlabs.com? Preferably Yii. Thank you!
I'm wondering if everything in PHP, can also be done in a framework without tweaking the core framework itsel
No, every framework has its limits but some are more flexible than others. For example, some frameworks don't allow you to connect to multiple data-sources with their model implementation. But if it's a decent framework, you should be able to extend or swap out those shortcomings with your own or another implementation.
Can I use PHP classes like geolocation, phpexcel or phpthumb
Yes, most frameworks allow easy integration with other libraries. I found a link showing how to integrate phpexcel with Yii:
http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/
Yes All framworks have proscons, but it's very important that how we will user them, i.e cakephp provide the helper class to create html and form but no need to use each and every time that because it will make slow your application
CakePHP have also cache memory limitation, we found in one popular auction script.

Using Symfony doctrine models in a REST framework

I have a web application which has been developed with symfony 1.4. I have a pretty large code base (and growing). Circa 80,000 lines of code (actions, forms, models, templates etc.)
I'm using the default doctrine version which ships with symfony 1.4.
I've just started developing a mobile version using Sencha touch. I don't wish to use symfony for the REST web services because:
REST services in Symfony 1.4 is not great. For example, If i want a PUT request I have to pass a 'sf_method' parameter specifiying that the request method is PUT. This isn't true REST and it's not ideal for Sencha touch.
I don't need all of the unnecessary symfony functionality(for example the plugins that are autoloaded in the ProjectConfiguration file, the form framework etc.) that you'd use to develop a standard web app. All I need is to define my REST routes and return the specified JSON (as everything that needs to be returned for Sencha touch will be JSON)
I want to keep my mobile app as bloated-free, efficient and quick as possible. And unfortunately for this task, Symfony 1.4 would not be the best choice for using as the backend architecture for my mobile app. If I had chosen symfony2 (it was in it's beta phase, alas) it would be a different story as symfony2 supports true REST functionality. What I do need, however, is the ability to use my current doctrine models (I have circa 90 models) in a chosen REST framework.
Basically, in a nutshell what I need is as simple as this:
Call a rest route->Query my doctrine models->return the JSON without using symfony.
So my question, what would be your advice? I don't want this to be a question of which is the best PHP rest framework, however, what I would like to know is what would be a good REST framework which i can develop efficiently and quickly REST service, make use of my doctrine models and is easily extendable.
Here at my employer, I've created a rather big application with a ExtJS frontend, and Symfony 1.4 backend. And two be honest, I don't feel limited by Symfony 1.4 in any way?
First of: I created my own base controller class (which extends sfActions). This controller can handle (render) different types of data. It has generic handling for Doctrine_Query, Doctrine_Collection, Doctrine_Model and array types.
Also the plugins make me help organize the code, and in some cases plugins are shared between differend projects, so that's also a big plus.
And the extra functionality like forms: it's only prepared for you in the autoloader, you don't have to use it. And I don't think it causes any real performance issues (at least not for me). But I like to use the extra sfValidator framework, to make sure data are correct.
The only real "problem" is indeed the HTTP REST-ful commands, especially PUT and DELETE. I just worked around this problem by generating a controller for each 'manageable' model, and implement specific get, list, create, update and delete actions. So when I would like to manage an Object, I call the objects controller, which has executeCreate, executeUpdate and executeDelete actions.
The reason I read, was that Symfony didn't and couldn't implement this feature because PHP has really bad support this. I don't know if this is true, but if this is your only 'real' issue, you could try to fix this in the Symfony core.
So my advice:
If the raw performance is your problem: try profiling your code, install a opcode (APC) cache, and profile your code (yes, that's double).
If the HTTP PUT command is your problem: I would either work around this (that's the way I solved it), or try to fix it in the core.

What is a good PHP framework for migrating an existing app to?

I've recently come on board with a PHP application. There has not been much design put into the app - there is a front controller, however, view, model and controller code is usually mixed together.
I would like to slowly start refactoring the code beginning with moving all the SQL queries into appropriate models. Having looked at a few frameworks, it seems that most frameworks are setup with the assumption that an app will be developed from scratch using that framework.
Is there a good framework that I can just kind of plug-in so that I can use the model libraries and then perhaps later on, integrate more of the app into the framework? Would Doctrine be a good tool for something like this? Or should I just setup my own models without relying on third-party libraries?
If you have an existing php application, then there is no point to migrate it to some framework. Frameworks help you to develop project faster - you already have one. At this point adding framework on top of what you have will only make your application more complex and, most likely, slower.
Instead of trying to find some magical framework, you should invest in refactoring (apply some OOP principles, like SOLID) and documenting the existing code. Maybe start incrementally add some unit-tests.
P.S. Doctrine is an ORM ( 1.x implements activerectord , 2.x - something like a datamapper ). ORMs are for people who are extremely lazy, misguided or do not understand SQL. By moving your existing SQL queries to ORMs code you will make it all only slower. Additionally, you will encounter problems when migrating complicated queries. Just dont do it.
I've just started rewriting a site in Kohana, and I'm quite happy with it. It seems flexible and powerful. It's very similar to CodeIgniter, but a little more modern (more of the latest PHP features are used).
If you want only MVC (not HMVC or more difficult) frameworks for simple adoptation with existing application you should touch CodeIgniter. ActiveRecords is very easy for refactoring from existing sql-queries. You even can use default or hand made functions or classes for building queries in its models.
But default, Codeigniter isn't enough flexible for difficult or multi-namespacing applications.
Im migrating a site using Zend and Doctrine2.
The site wasn't OOP in any sense but it was divided between logic view and dal. The migration is still in process (new features are coded with framework, existing feature gets migrated only when big changes are needed).
Both frameworks are non intrusive, and the most valuable thing you get for me is to standarize things.

What are methods for migrating from one technology to another?

I'm working on a project using Zend Framework, which I initially chose since I had a bit more experience in it. At this point in time, I'm thinking of moving to Django, though, as our current team will be more productive in it.
I'm trying to figure out the best way to (potentially) go about this, as we evaluate it. A lot of our code is still fairly fluid, and being re-written fairly often. The way I had considered is that as something ends up being re-done, redo it in Django, and change my PHP model to simply be a call to the Django underbelly and translation to PHP. Over time, we should have all of the models, at least, in Django.
Are there better ways? Particularly, is there any way to easily manage having two codebases at once?
There is no generic answer to cross-language migration projects.
If you can wrap your php code and hide it behind web services, you will be on a good path because you will be able to migrate those web services later without changing the API.
Make a list of the main components of your architecture and try to see which ones could be hidden behind such a web service API.
I would recommend that if your web app is db driven, move your business logic to your db and have your data mappers call db stored procedures. I'm developing using ZF myself, which is a very strong tool, but the immense 'abstracticity' it offers can deviate you from your goals... Then you can mess as much as you like with your controllers and views...

Categories