CodeIgniter support for AJAX, and ORM - php

I was searching for a good php framework for my next project, and I found that CodeIgniter is suitable, but I read this somewhere "codeIgniter has No ORM(Object Relational Mapping), No AJAX support", is that right?

"codeIgniter has No ORM(Object Relational Mapping)
TRUE. But it has a nice and handy custom Active Record class which acts as an ORM, supporting many database drivers; as of 2.0.3, supported databases are mysql, mysqli, postgre, odbc, mssql, sqlite, oci8.
And, if you want, you can just add your favourite ORM to the libraries or drivers and you can use that instead. There are many tutorials out there and answers on SO if you're stuck with this procedure, though it's pretty easy and the manual is really clear on how to create/use custom libraries.
No AJAX support
Whatever this means, it's not true. CI is a php framework for web development, so write your javascript ajax code inside views, call the right controller's method, and AJAX will work just fine.
If you mean there's no native support for that, i.e. using native classes to the task, then it's partly right. CI has the javascript class which is a loader/helper for jQuery; I never used it since I prefer loading that framework by myself and working directly on that, but you might give it a try.

Yes, CI has no built-in ORM. but it supports different libraires and classes which acts as ORM.
for example:
doctrine and data mapper
can be used along with codeigniter to fulfill your requirements.
as far as CI support for AJAX is concerned, AJAX works perfectly fine with codeigniter. Do keep in mind when developing using Ajax, that if someone turns off Javascript in their browser, what you develop will not work.
Hope this helps.

Related

Latest PHP Framework with ORM in Linux environment which support SQL Server

I've been searching for a Modern PHP Framework just like this post's title. I've tried Yii, Laravel, Doctrine, they do not support that (I really like Laravel).
I've been using good ol' AdoDb PHP DBAL library for SQL Server in Linux, but combine it with Laravel seems impossible...
Anyway, I'm going to check CodeIgniter, SilverStripe, CakePHP, and Zend Framework (last).
If all fails, then I just go with Laravel and make web-service-interface for SQL Server using NodeJS, but the power of ORM will be gone.
I just need some pointers, suggestion, success stories, or anything...
Thanks
EDIT01
Maybe PHP Framework with some kind of technology like Ruby's ActiveResource where the database model is a RESTful web service?

Which MongoDB library to use for a stand-alone PHP project with Symfony?

I am leading a new project where we're convinced that MongoDB is the right choice for database. We have decided that the architecture would be SOA, so the web part will be developed using Symfony and the service part will be developed using light-weight REST framework Tonic.
Now, in the service part, we'll be communicating with MongoDB and for that, we have looked into a number of available MongoDB libraries: Doctrine MongoDB ODM, Mondango, ActiveMongo, MongoRecord, etc. However, we are not sure which one to pick.
I was wondering if anyone can share their experience with these libraries so that we can make the right choice. Here are some of the properties we consider the library should have:
Plain PHP classes for defining documents (instead of array/config files)
Support for references
Efficiency in operations
Easy to understand API
Looking forward to your views!
Personally I would go with Doctrine2 ODM. Seen as you have already decided on Symfony as your framework for doing the heavy lifting the pair are well aligned as far as I understand. You should be able to use this https://github.com/doctrine/DoctrineMongoDBBundle to integrate the two pretty quickly.
The doctrine setup ticks all the boxes you've set for your project goals and is fairly easy to get working with. Most importantly, it's an active project so bug fixes/features/documentation updates happen fairly regularly.
We use a similar setup, except zend framework instead of Symfony, and we're very happy with the results.
Hope this helps.

Are there any other PHP frameworks like CodeIgniter?

I am looking for a "lite" php framework like codeigniter that doesn't generate anything or make me follow conventions, etc. I have a lot of legacy databases to connect to and I don't know whether or not CI will be able to connect to them all so I thought I'd see if anything else is out there.
Again, not after anything that worries me to death about singular and plural names, makes me have a database in a certain fashion, or anything that gets in my way. No offense by that. I have other projects where that is just fine and I use RoR for that. I just don't want that here because if a framework is built around that like RoR is they tend to be difficult to use with existing legacy databases.
Thank you.
CakePHP is the most popular.
There's a fork of CodeIgniter called Kohana.
The connectivity to the legacy database shouldn't be an issue of the framework though, I guess it's more a PHP issue if the connection won't work.
http://alternativeto.net/software/codeigniter/ Will give you a few alternatives.
Check out Laravel. http://laravel.com/
It is really clean and well documented and has some really useful features which I didn't find in CodeIgniter or CakePHP which I previously worked on. I tried it out for one of my recent projects and I was really impressed !
The Zend Framework might be your best bet:
Zend Framework is an open source,
object oriented web application
framework for PHP 5. Zend Framework is
often called a 'component library',
because it has many loosely coupled
components that you can use more or
less independently.
Since you can use the components independently, you will have more flexibility in choosing your models and data access. Be warned though, there is a steep learning curve.
apparently Qcodo is supposed to be a lot like rails according to http://gadgetopia.com/post/4726
other than that (and symfony, Yii, and CakePHP) if you're comfortable with CI, do go for Kohana, as Cassey mentioned
You could also just use PEAR or some wrappers. if you have legacy databases I wonder if you might have older php/mysql tht it sits on, in which case a lot of the newer frameworks that are updated for the latest/greatest might not work for you anyway.
I'd look at Kohana or Yii. Sure, Yii has scaffolding, but you don't HAVE to use that if you don't want to. Just as with Ruby on Rails.
Both are MVC frameworks that are very object oriented. How you connect to databases is totally up to you.
You can use the ORM in Kohana without following their naming conventions, you just have to let the Models know the name of your tables and primary keys (otherwise you have to follow the convention, of course).
Check out Symfony
The last version is very lite and all extra packages are optional and the core is so lite and also it is so clean and well documented .

CakePHP to CodeIgniter conversion

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.

What's a good way to encapsulate data access with PHP/MySQL?

Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files.
I like to keep things simple, even with .NET. I generally write stored procedures for everything, and I have a helper class that wraps all calls to execute procedures and return data sets. I'm not looking for a full-blown ORM, but it might be the way to go and others who view this question might be looking for that.
Remember that I'm on a $7/month GoDaddy account, so I'm limited to what's already installed in their basic package.
Edit: Thanks rix0rr, Alan, Anders, dragon, I will check all of those out. I edited the question to be more open to ORM solutions, since they are so popular.
ActiveRecord seems to be the state of the art at the moment. I can't recommend any good PHP frameworks for that though. I tried Propel which, while nice, is not easy to set up (especially on a host that you can't install anything on).
Ultimately, I rolled my own ORM/ActiveRecord framework, which is not too much work and very instructive. I'm sure other people can recommend good PHP frameworks.
Take a look at the Zend Framework, specifically Zend_Db. It has a Database Abstraction layer that doesn't require anything other than the MySQLi extension to be installed and isn't a full-blown ORM model.
Maybe Doctrine would do the job? It seems to be inspired by Hibernate.
rix0rrr hit on it a bit, in that many tools are a pain to set up. Of course, I have my own solution to this problem that has been working quite well for the past few years. It's a project called dbFacile
I also wrote a bit of a usage comparison of the tools I found a few years ago. It's incomplete, but might give you a good starting point.
You mentioned that you don't want to embed raw queries but you don't want ORM, so I'm a bit confused about the middle ground you're hoping to find. I also have an ORM project that aims to require minimal setup and great ease of use.
The only requirement for my projects is PHP5.
I would try a framework. Zend Framework has been cited. Symfony seems interesting. It's based on ideas from Ruby on Rails.
You could also take a look at Prado. http://www.pradosoft.com/ It uses Active Record and DAO. Also if you use .Net then some of the formatting and conventions are similar.

Categories