PHP: Migrating From oop without Framework into Zend php frameword - php

I have completed my website couple months ago, in php 5 (full oop), and now I'm think of migrating into PHP framework (Zend looks fine).
My question is, how hard is it to migrate from oop to any php framework?
What is the easiest Framework i can migrate to?
Noting that Functionality of my website depends on:
A lot of MySQL Searching and Updating.
There is a lot of forms in the web, some of them can reach more than 50+ fields.
A lot of classes that handle logic of website specially analyze submitted forms with data on database.
I have no experience with php frameworks, so can you please tell me which framework would be least painful to move all my classes there and get them running fast?

How hard is to migrate... is a good questions...
A little example:
You can write your own queries... You can write queries in a "ZF-like" style...
then if your OOP Classes are well formed (I mean well formed for use them into the ZF enviroment) your migration will be quick and easy...
but you also have to understand ZF Mechanics
Keep a look to those beast:
- Zend Forms
- Zend Decorators
IMHO the two beast of ZF

If you switch to ZendFrame work you need to convert
your sql queries using Zend Db
You need to convert your forms into Zend Forms.
Zend provides classes for form validation. So you need use Zend Validation Classes for the form validation.

The question is like
How long is a piece of a string?
We don't know your application, the information you gave us is too vague and we don't know your experience in php at all. Porting code from one architecture to another can be easy (if the basic styles and techniques are the same) or pretty impossible (if you wrote a spaghetti application).
Also the question for the best framework to port to is impossible to answer, as long as we don't know your application.
The main question is: Do your application make use of design patterns (and do you understand them fully),or is "OOP" just the use of classes instead of functions, for you?

Related

Scalable app design in php

I'm a beginner php developer who is trying to build a social network for my school students. Knowing that the school has over 1000 students who are already active, I must have a plan of expanding / scale the code that I write.
Earlier it was just the LAMP Stack, now the modern web development is way more than that as I see, I'm truly kind of lost in what technologies to use and how to incorporate them to build a scalable app. I'm hoping to divide this application into 3 layers.
Application layer (phalcon,reddis,apache,php)[mvc api centric]
Database layer(mysql)
UI layer - (html/css/js/)
This is where i need help, is this design approach good for a scalable app ? where can i improve ? any explanations, links for further reading will be a highly appreciated.
Welcome to SO. I cannot think of a particular reference guide to direct you to (although the PHP manual is a good place if you end up stuck with how to do something specific). I would suggest reading a bit of several results when you search "Getting started with MVC in PHP" and noting what they agree on. That said, take a look at what I say below (and then ignore it as much as you please ;) ).
Firstly, you are wiser than many in sorting out a scalable design before launching into the project...
I'm excited to see Phalcon in your list there already. However, as DevDonkey suggested, start with something simpler first (Phalcon is very powerful but to really get to grips with it you need a good grasp of PHP, particularly object-orientated programming).
If you are completely new to PHP...
... try building a small app (products table, view/add/edit/delete functionality) and learn the beginnings of the language that way, as this answer suggests. Things will go wrong and you'll discover lots of headaches when you want to change one feature and it affects everything else but that will help you to understand the importance of...
MVC design
From your question I can see you have at least heard of this. This is really where the layers of your application lie:
Model - interactions with the database (retrieving/editing data) are handled through this. So you could have a MYSQL database and then your models provide a nice interface to interact with the data (generally you have one model for each table).
View - this is the last layer, what the user sees. So you will make use of your html/css/js knowledge here. On this topic, unless you really want to do your own css consider using a CSS Framework such as Bootstrap. It will really help speed up making your site look good and there are loads of free templates out there to use with it.
Controller - this is the application logic. The controllers request/manipulate data through the models and then decide what to send to the views for rendering.
Use a framework?
Using a good framework can make your application more reliable and quicker to build. But using a framework without understanding it will be frustrating, slow and possibly result in worse code than if you didn't use one to begin with (as you employ hacks to get around the pieces of the framework you don't understand). My current favourite is Phalcon but as a relative beginner to PHP I would suggest something more like CakePHP although both Laravel and Symfony are also popular.
Summary
Start small, learn, test ideas out and then build up to a bigger project.
Get comfortable using PHP (including OOP style) before using a framework.
Use an MVC framework
The layers you laid out in your question are good, but I would split it slightly differently (considering that MVC is the 3 layers)
Application Layer - controllers, written in PHP, handles logic/manipulation, often the biggest layer
Database Layer - models, written in PHP, you will also need a database which could be in your favourite database language - MySQL ;)
UI Layer - views, possibly written in PHP (depending on the framework) but also HTML, CSS and JS as well as well as a templating language if you wish (e.g. Twig or Volt), essentially a way to make the response from the controller nice for a human
First Project (for CakePHP)
This blog tutorial is a good place to start if you decide to use CakePHP.
Getting started with Phalcon
Phalcon is more powerful/verstile, but to get started with it I feel you have to be a better PHP developer than you do to get started with something like CakePHP. Take your time to understand each new concept with Phalcon, particularly Dependency Injection.
Even having used CakePHP for the past 2 years and being familiar with MVC patterns and PHP, I still worked my way through all 7 of the tutorials in Phalcon.
Having said this, my favourite thing about Phalcon is that it is highly decoupled - so it is fairly easy (after a while) to replace bits of it with your own extensions if it doesn't quite do what you want.
Note about Phalcon: It is not as popular as many other frameworks (although popularity is growing) and so you may have to spend some time digging around when you get stuck. However, the docs are improving all the time and the forum is very active. Unfortunately the number answering questions about it on StackOverflow is still small compared to many other frameworks.

PHP framework of intermediate complexity, in between CodeIgniter and Yii?

Something easy like CI (this means mandatory good, easy, up to date documentation). But also with some more features than CI.
Yii has lots of features, but it is also more complex (and it kind of forces you to have to use lots of it features). That means adding some functionality to your web-app takes three times as long because you have to figure out lots of new small functionalities of Yii.
It's kind of like the CI "gets out of your way" when it needs to, and Yii gets in your way, and if you don't do it its way, it breaks.
Features missing in CI that would be nice to have in this new "intermediate" PHP framework:
Code generation (crud).
Authentication.
Access control.
Layouts.
Widgets.
Easyer / automated pagination (like yii)
easy uri parameters
Where Yii causes me problems:
It's like for every small task there is some inbuilt functionality (this is good), but, YOU HAVE to use the inbuilt functionality, otherwise bad things happen. (CI gets out of your way, but does it too much, Yii helps a lot, but is butting in too much at times, and it forces you to sift through its documentation so that you discover these functions without which you are not able to accomplish a task that would take four time less, in CI, or in a non framework app).
Is there something in between ?
(ASP.NET MVC could be 'it', but I don't know the language, so the effort to learn it would be greater than learning Yii php framework really well, so I am looking for a PHP Framework)
I am a fan of CakePHP. I feel it has the specs you provided. If you want something more cutting edge you can take a look at Lithium
I have found some resources that kindof solve the problem, because they contain examples (Milan Babuškov's sugestion helped focus on "the solution").
Yii playground - examples
Yii cookbook - examples
Yii blog tutorial - more examples
PS. there is also google - I find solution (and examples) the fastest this way - ex: implement + pagination + yii
I've used both CI and Yii (on my own projects if that makes any difference). CI was my first introduction to MVC, and I found it easy going because it let me use any crappy structure and code. I wrote two full sites in CI (www.insolvencynews.com and www.thebigeat.com if you want to see complexity.)
I had a look at CakePHP but got NOWHERE.
Then I moved on to Yii and, like you, I found it pretty tough and rigid. But I then found that it was so powerful and extensible that I was so much more efficient. When I needed to add a few new features to the old CI sites, it was faster to rewrite the entire sites on Yii than to code up the extra features in CI.
I can't recommend a framework in the middle, but I can recommend sticking with Yii. When you say Yii gets in the way, can you give an example? Looking at DB stuff (in ascending order of dependence on Yii):
you can code using PHP's core MySQL functions.
$result = mysql_query($sql);
you can use Yii's DB abstraction layer.
Yii::app()->db->createCommand($sql)->queryAll();
You can use Yii's ActiveRecord:
Takeaway::model()->findAll();
you could try kohana (especially coming from ci)
You should check out the CI community, some of those extensions maybe have been written by someone else (I remember seeing Authentication and Components/Widgets somewhere)
Symfony is worth checking out. I personally don't like it much because they chose Prototype over jQuery for their ajax features, which is really annoying to use when you're used to jQuery.
Lithium might be good to check out too. However, it is php 5.3 only and you need to be really careful that this version of PHP is going to be supported on the server the site will be deployed on.
See this list for good comparisson:
http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#PHP_2
From a personal point of view, I would go with symfony because of it's
rich features and
great integration with many other already bundeled components (Doctrine, Swift Mailer,..),
good (but at first complex) code generation that produces realy useable code to get you startet quickly,
powerfull use of templating (that will be the point you mention under "layouts)
many different, powerfull plug-ins, including Authentication & Access Control (it also has a plug-in to get jQuery support)
one of the best tutorials that I've seen with a framework
Downside is a
more complex structure,
IMO wired file structure,
a rather messy API documentaion compared to the tutorial
CodeIgniter is a nice framework if you don't want to create big apps but it lacks a great database integretaion and you already mentioned code generation.
im very good in Raw PHP, where the project at hand became too much to handle i decided to move to zend, with too too much complexity i finally moved to YII which really reduced the cost and overhead time for project development and most importantly for me is the simple integration of jquery, widget and advanced-OOP.
You could have a look at Qcodo / Qcubed.
They are both easy to pick up and offer code generation / ORM
Easy way to create forms in an mvc kind of way.
For what its worth, if you're looking for a PHP Framework that is like ASP.NET MVC then I think Prado is the closest thing you will find.

How do I make non-framework code to framework code? (PHP)

I just started using CakePHP and it's very different from just normal procedural or basic OOP PHP.
I am still learning PHP and still read "beginning PHP/mysql" books that teaches you basic PHP. Also lots of sites online provide code that isn't for a framework.
Is the only way to make non-framework code to say a framework, say cakePHP, by learning cakePHP thoroughly than rewriting the code yourself to fit the MVC model?
I think it would be beneficial to learn basic OOP PHP thoroughly before learning CakePHP. I admit Cake is a little restricting about naming conventions but you can customize this to your liking. I would try to rewrite a small PHP application in Cake to get familiar with it. Choosing a MVC framework does save a lot of development time if you take the time to learn on well. For Cakephp the book and API are two very valuable tools. I also suggest using Cakephp 1.3.
API
Book
CodeIgniter allows you to write things the way you want but really works best when you use it as a MVC platform. You would write all of the PHP code in the controller if you wanted and the application would still work, you could then decide to split out the code for the database into the model and then later decide to put all of the HTML into the view. That's if you would like to do it like that.
I would recommend doing tutorials and trying to use the MVC model as it has saved me a lot of time and is so much better than flat file coding.
CakePHP can be a little restricting as it requires you to follow particular naming conventions.
Hopefully this gives you a good start on a road to learning the ease and speed of MVC.

Rewriting a php app in CakePHP

So, I'm very tempted to rewrite my application using a php framework, as I think it'll make it easier for folks to get involved, as well as improving the design of the app.
CakePHP looks like the best of the PHP web frameworks. Does anyone have any experiences of it? What are the caveats I should consider going from handcoded PHP to using a framework?
Not depending on the framework you'll chose, the first thing you have to know is that :
it'll take some time for you to know it
you'll do crapping things, during that time ^^
so, take into account the fact it'll take some time before you are fully operational :-)
I think those points are the most under-estimated points : using a framework takes not much time... Using it well and to the full extend of its abilities takes... Well, a couple of months, maybe... Which means, when you are at the end of your project you'll say "I should rewrite that with all the stuff I learned while re-writing it the first time" :-D
What it means is : learn what the framework can do, learn how to use it, and use it for a while on small applications, before starting rewriting your big one !
Then, there is probably no "best framework" : one framework may be very well suited for one project, and another one may be best for a second, different project.
I've never worked with CakePHP ; I really like Zend Framework. But that is a personal opinion, and O know people who really like symfony ; they are not wrong : symfony is great -- and I am not wrong either ^^
Still, we sometimes agree on some things ; like the fact that Doctrine (default ORM layer of symfony) is really great stuff, and we tend to use in both symfony and ZF-based projects...
If motivated, you can take a look at many posts on SO, about frameworks... Here are a couple of those :
What PHP framework would you choose for a new application and why?
Is Symfony a good framework to learn?
What, in your mind, is the best PHP MVC framework?
Is Symfony a better choice than Zend for a web development shop (10+) because it is a full stack framework?
Best PHP framework for an experienced PHP developer?
Good luck with those ^^
("Which framework" is a quite pationnating -- and subjective -- question ^^ )
CakePHP has it's good parts but there is no "best" framework. Here's a thread with some clues about what's good in most popular PHP frameworks.
If you never used MVC frameworks before (and Cake is MVC framework) I think you should first familiaze yourself with MVC architecture.
"CakePHP looks like the best of the PHP
web frameworks."
This is subjective. You should compare the pros/cons of other PHP frameworks that will suit your needs.
These posts may help you:
https://stackoverflow.com/questions/2648/what-php-framework-would-you-choose-for-a-new-application-and-why
Why do I need to use a popular framework?
https://stackoverflow.com/questions/249984/php-framework-decision-analysis-paralysis
FWIW, I used it for a time when I was doing some php development. I found it easy to use, and the rapid development aspect was great, and I would imagine has just gotten better in the last 3 years. There is a ton of help in the irc channel, and the documentation is good. I didn't stick around in PHP long enough to become an expert. However, I was just starting out as a programmer then, and ran into Larry Masters (the creator, aka phpnut) and he was just a good person to talk to about design principles, and an all around nice guy. Then again you don't have to be a super nice guy to write a good web framework (I'm looking at you DHH).
Most of the frameworks "bind" you to them, meaning you have to do things their way. If you want to do something they weren't designed to do, you usually have to hack it. For example, how many PHP frameworks currently support Facebook Connect?
Personally I prefer "frameworks" that you can use only the parts you want. Zend is like this, Doctrine and Propel are ORM that are designed to be used with other code. For example, the Symfony framework can use either.
Finally, I haven't found a popular PHP framework that scales well.
I have used cakephp for a couple of projects. From the moment I learned it I have never written php again without it (unless is fun code in which I want to try some new stuff, or learn other design ideas away from MVC). As mentioned, learning it will take some time. How much time it takes really depends on your background. If you have used another MVC framework for a web scripting language then you will learn it really quick; RoR developers will pick it up within hours/days. If you don't have experience with MVC frameworks then it might take you a little bit, but it will really save you time later on the road (including in that project you start with).
Until today, I still learn new things about CakePHP every time I start a new project on it, although I do dig into a lot of its source code (you definitely don't need to do this, documentation and help boards are more than enough).
I definitely recommend you looking into it. It will save you a lot of time and get your head thinking in a different way (if you are not used to the MVC).
Best of luck.
CakePHP's convention over configuration approach has a few advantages once you learn them:
it helps to keep you code organised and understandable
makes it easier for multiple developers to collaborate on the same application
makes it possible for developers to understand other developers' applications
You have two main options when rewriting a legacy application in CakePHP:
change the database schema to reflect the conventions - resulting in less code
code your models to interface with the legacy database - this book goes into all the details
Either way, once you have done the above, it's pretty much plain sailing, and a good learning experience.

Ruby on Rails or a PHP framework

I am a capable programmer and I write software for a living. I am taking up a new project to build a website that has a bunch of forms that perform CRUD operations on a database and some multimedia. I am very familiar with PHP and Python and have written some websites in them. I have written some rake tasks and a few ruby scripts that run in production, but I never wrote any websites in ruby. I am considering using Rails, but I have the following questions. It would be great to know the answers to any/all of these:
The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR?
Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them?
I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. Is this correct?
I need to create a website that displays a lot of Images, videos and Java applets. Would RoR hinder my ability to do this?
I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience.
Answering your questions in order:
You could certainly learn Rails in that time. It's enough time to build a Web site too, but whether it's enough time for you to build your Web site is a different question. I would personally not want to try such a thing on a tight deadline.
You can write your own SQL queries, but there's little point to using Rails if you are going to work around all of its features.
Joins are normally done as part of the database queries generated by ActiveRecord.
Using ROR is pretty much orthogonal to having images, videos, etc. on a page.
I haven't used it, but CakePHP aims to be quite Railsy. Zend and CodeIgniter are more popular and I'm told better by people who have used all three, though.
The project should be done in a month
and is very time sensitive. Is 1 month
enough for learning with and building
a website in RoR?
Given the experience you describe I imagine one month to learn and build a simple-ish app (especially if it is CRUD based) should be enough. If there is a significant level of complexity I would be loath to learn a new technology and deliver a complicated site in one month.
Writing direct SQL
queries is one of my strengths and I
would like to use it. I heard that RoR
is a pain to use if I am writing SQL
queries directly. Is this true? Or can
I just say execute a query, give me
the results (as a list or dictionary)
and then I will tell you how to render
them?
The rails way is to use the ActiveRecord object mapppings it gives you (and mostly these work very well) It is also very easy to write direct SQL if that is what you want to do
ModelName.find_by_sql('your query')
is how you do that
I have heard that RoR does joins
in memory and doesn't use the
facilities offered by the database. Is
this correct?
ActiveRecord does a lot for you, but wherever performance is an issue, as above you can write your own SQL to leverage the advantages of the database.
I need to create a
website that displays a lot of Images,
videos and Java applets. Would RoR
hinder my ability to do this?
I don't see why it should. There are lots of gems and plugins out there which help with this sort of functionality, so it may well be the case that a lot of code could already be written for you.
I am OK
using a PHP framework. Is this a bad
idea? If not, which PHP framework is
closest to Rails in terms of
programming convenience.
I'll let a PHP expert answer this bit.
The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR?
If it's time-sensitive, stick with what you know.. That said, Rails has lots of plugins to handle things like image-uploads which may save you a lot of time. Rails has "scaffold generators" which create basic CRUD applications in a single command:
./script/generate scaffold title:text description:text when:datetime
..will generate the controllers/views to create/edit/delete items. You can then easily wrap nicer looking HTML around it, add authentication (via restful_authentication), and you may have your completed application in a few hours..
Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them?
There's very few situation where you'd need to write SQL with ActiveRecord, but you can. RoR is still Ruby code, so you can always use a MySQL library and do away with ActiveRecord if you really need to write raw SQL (but, again, you almost certainly don't)
I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. Is this correct?
There's no reason ActiveRecord cannot perform JOIN's via SQL queries, the ActiveRecord::Associations::ClassMethods mentions associations being performed via JOIN's.
Besides, even if it does do JOINs through memory, it's worked perfectly well for however long Rails has been around..
I need to create a website that displays a lot of Images, videos and Java applets. Would RoR hinder my ability to do this?
No. They're all just bits of HTML, which Rails can output as easily as any other framework.
I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience.
Absolutely. If you don't go with Rails, use a PHP framework!
I would recommend against choosing a framework based on "how close to Rails" it is. PHP isn't Ruby. Trying to "port" (in a manner) a framework to a different language rarely works as well as writing a framework for that language.
As I commented on Chuck's answer, "CodeIgniter and Zend are good PHP web-frameworks. CakePHP is a good Ruby on Rails imitation"..
I found CodeIgniter felt much more like PHP (in a good way), it's documentation is also my favourite of any project I've used!
The Zend Framework is very modular, you can drop bits of Zend into an existing PHP app, or use it's MVC routing system.
CakePHP seems to be trying to make PHP act like Ruby, rather than making a framework that fits nicely with PHP.
All that said, the reason you use Ruby on Rails is the community (and thus all the plugins and stuff that revolve around it).
For example, paperclip plugin makes it extremely easy to an image-upload form (along with thumbnailing). To use it you add (to your model):
has_attached_file :photo, :styles => {:thumb=> "100x100#", :small => "150x150>" }
Then in your view, where you want the upload form to be, add:
<% form_for :user, :html => { :multipart => true } do |f| %>
<%= f.file_field :photo%>
<% end %>
That's it.
What I would recommend is spend a day making something simple in Rails. There's countless great tutorials (Railscasts are a good, random, example) and plenty of books on it. See if you like it, if not try CodeIgniter, Zend or CakePHP (or Django, or Merb, or.... Just don't spend the whole month trying frameworks!)
As you have some Python experience have you had a look at Django?
Rails is great for CRUD stuff.
1 - If you're already familiar with Ruby and MVC, a month should be fine. If not, there's a lot to learn.
2 - Rails will let you execute SQL queries, but it's really set up to take advantage of ActiveRecord.
3 - Rails is designed to switch between database types, so ActiveRecord does a lot on its own. Look into ActiveRecord Associations for more info.
4 - Never tried Java applets, but the rest work fine.
5 - If you're more comfortable with a PHP framework it's not a bad idea at all. There are even a few that try to replicate a lot of Rails features, such as CodeIgniter.
Check out RailsGuides for a better idea about all this.
I am OK using a PHP framework. Is this
a bad idea? If not, which PHP
framework is closest to Rails in terms
of programming convenience.
I guess CakePHP is close to RoR for a PHP framework.
I have not tried Rails myself, but wonder if it is a convenience. As far as Ive read (like the guy who spent 2 years making Rails do something it should not) when you need to do something more complex you apparently have to fight and hack the framework.
There are other frameworks for Ruby, PHP and Python. I suggest you look around a bit more before you decide.
If you want to code in PHP you could try Symfony with Zend Framework.
The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR?
It could be, but it could also make things unnecessarily harder on you. I usually wait for a project with a relaxed timeline to try and learn a new technology. If time is of the essense, bust out your favorite language and get it done.
Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them?
I am not a Rails developer, but I do know it uses ActiveRecord. I am sure, however, that there is also a way to make it execute raw queries as most ORM do. Right there however you're going against the grain of what the framework wants you do and you may run into problems.
I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. Is this correct?
Anything that abstracts out things for you, particularly database relationships, is going to be far from efficient. Worrying about it beforehand is usually not necessary, and once your application is finished it is common practice to then identify any particular slow queries and redo them by hand if necessary.
I need to create a website that displays a lot of Images, videos and Java applets. Would RoR hinder my ability to do this?
I have no idea why it would.
I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience.
CakePHP is by far the closest framework to RoR. It borrows from a lot of its ideas. I have used it with some success in the past. CodeIgniter, while not related to Rails, is also terrific if you want something lightweight that won't force you to do anything its way.
http://www.doctrine-project.org/
I've had great success with the doctrine ORM : if you are writing object oriented php then this does the object->database record mapping for you. AFAIK this is one of the plusses to the django / rails framework.
So this links up the oop/database functionality like this:
$foo = new User(); // makes a new 'transitory' user object
$foo->name = 'bob'; // works like you'd expect
$foo->save(); // but this pushes it into the database.
//(There's a 'name' column in the 'User' table already: set up when Doctrine initializes).
& if you want a framework, it's a part of symfony now.
It's very motivating to have a real project to learn a new technology or approach, but it is possible to take on too much. It'll take 5 times longer than you'd take in the technology you know. Which can be okay - the learning, and the results might be worth it. But doesn't sound like this is appropriate here.
Rails is a great framework, but learning that framework and becoming more familiar with constructs specific to Ruby might be a bit much to do simultaneously with a one month deadline.
To step into a web application framework, I would recommend using a PHP framework if you are already familiar with PHP. While not a port, CakePHP is very much similar to Rails. It is modeled after Rails, and is my favorite PHP framework. symfony is a solid framework, but if you're looking for something more Rails-esque I recommend you try CakePHP.
If you're not already married to using Rails or something like it, I would recommend the Zend Framework. It is by far the most comprehensive web application framework available for PHP.
All of these frameworks will allow you to do all of the things you mentioned. It might be easier to think of them as a select group of building blocks than a comprehensive operating system for your website that you extend with plug-ins. That would be more similar to a CMS like ExpressionEngine. You can do anything with these frameworks, they're simply code bases for you to draw from to make developing web applications less tedious.
The Akelos framework is a PHP framework that purports being a port of Rails, so you might also be interested in that.
As for writing SQL queries, it's possible with any PHP framework, but the idea behind these frameworks is convention over configuration. Each has its own ORM scheme to abstract SQL queries away from the developers. While this might be due to the fact that many web developers, at least in my experience, are terrified of SQL, as someone who also likes writing SQL, I do appreciate the massive amounts of time that an ORM framework can save. Again, when the application is developed it's pretty much standard practice to profile the ORM's performance and look for areas to improve. Rapid-prototyping is a huge part of web application frameworks, so tools like this might actually be a hindrance to you. Like others have said, using one of these frameworks might end up being pointless if you're just going to work around their facilities.
Should you decide not to use one of these, PHP has a plethora of mature projects that will help you build an application, but seeking these out and learning how to implement them may take a great deal longer than learning a framework.
IMO a month is very tight to learn and launch in a month ( I'm assuming you're not full time though ) and you wouldn't be full time if you're learning as well. You know how it is when you get deeper.
About a month ago I faced the same dilemma between RoR and MVC. After a few weeks (learning at night ) I learned enough about RoR framework but ruby language was very new to me, the client wanted delivery and I was still in the "playground/sandbox" phase
So, because I know c# and the .net framework well and I can find resources quickly I have since open for MVC and within 2 weeks I've delivered something to the client.
So in my experience, learn RoR give it a week. If you're finding it takes more than say 40 hours to get going with the actual application, then stick with PHP and do RoR when you have more time and less time restraints.
Goodluck either way though!!
If you're comfortable with Model View Controller stucture then Ruby on Rails isn't too hard to learn. I myself came from PHP's Zend Framework to Ruby on Rails and really found it a relief. I like the whole idea of convention over configuration that Rails uses. It keeps your application (and all future applications) well structured, which in my option is extremely important and time saving.
At this time I've been programming in Ruby with Rails for maybe about 6-7 months and I'm really enjoying it. Clean code, VERY fast development, it's really incredible. Especially with the generator files and database migrations.
As for RoR being a pain when writing raw queries, I'm not sure, I never even have to write them but you sure can with a simple method. That shouldn't be a problem.
Once I started developing web applications in Ruby on Rails, I did not want to go back to PHP. Purely because I'm pretty much in love with how Rails works, the conventions, rapid development, clean code, consistent structure etc etc etc. But these days I now and then still get asked by clients to develop a web application with PHP. But in my eyes, if I went back in to Zend Framework I'd probably really get stressed as I find it extremely inefficient. (That might be my own fault, I'm not sure, but in my eyes, compared to Rails, meh). I discovered the PHP Framework "CakePHP". This framework is as far as I know the closest thing to Rails and I currently use it to develop PHP applications. It's pretty straightforward and works great. It also has a VERY nice thing called the "cookbook" on their website which helps you get up and running very quickly. So if you were to choose a PHP framework I would personally go with CakePHP just because its the closest thing to Rails.
The only thing I myself am a little annoyed about with Rails is that it requires a certain version of Rails to be installed, and that version must be compatible with a specific version of Ruby. You'll need to get the hang of Gems, Plugins (which aren't hard to understand, to be honest). But along with deployment, if you're running Apache 2+ then you need Passenger. Also to be safe you will want to freeze your gems and that kind of stuff to avoid conflicts with the servers specifications and installed utilities.
There's a lot more to learn than just the language and the framework when it comes to Ruby on Rails. PHP is pretty simple, just upload and it works. So you might want to look in to that as well before developing the application.
I think Rails is great, and it would be my first choice for such a project, but if you are in fact under a tight deadline and you are starting from square one with Rails, just don't do it. Go with what you know. PHP might not be the greatest, but it's a very serviceable language.
Despite what people might say, Rails does have a non-trivial learning curve, especially if you are not familiar with MVC. There's definitely a "Rails Way" to do things, and coming from most other frameworks, it takes a while to grok.
I think if you try to rush and learn Rails, you're just going to get frustrated, and I'm afraid this would taint your impression of it. Instead, try learning it in your spare time, or on a project with a more relaxed timeline. I think you'll get a lot more out of it this way.
I think adding the complexity of rewriting what you already know in a month - on a time sensitive project is a bad idea. Using any framework/tools you are unfamiliar with is probably a bad choice on any "time sensitive" project.
That being said the Zend_Framework for php is pretty solid with its form abstractions. I found an easier time moving to ZF than RoR - I tried both at the same time.
The documentation for ZF is fair - reading the actual code of the library is still my best source for documentation though. It isn't that tough to learn or start up - and if you don't mind IRC / stackoverflowing questions you should be able to learn it pretty fast.
Don't board the Rails train just because it looks cool. I know it's what everyone is talking about these days but to be honest, it's really not that special and you'd be better off using a framework written in a language you are comfortable with. If you are really good at SQL then it would take longer to learn how to use ActiveRecord than to just write the queries by hand, and ActiveRecord is basically half of Rails, which kind of defeats the purpose of using the framework. So based on the background info you provided, I'd say go with a PHP framework like CodeIgniter (haven't used it myself but I heard it's great, sounds like what you need).
The project should be done in a month
and is very time sensitive. Is 1 month
enough for learning with and building
a website in RoR?
As its been said before, stick with what you know if the deadline is short.
I am OK using a PHP framework. Is this
a bad idea? If not, which PHP
framework is closest to Rails in terms
of programming convenience.
CakePHP is very ruby like and I have been told that its a good stepping stone for PHP programmers to get in to Ruby and MVC.
use php + Zend Framework it's have all features of ror and more faster
ror is very slow, very expensive, and require powerful server
* The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR?
it's enough to learn Zend Framework
* Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them?
should to writing SQL queries directly, ror make very slow and unoptimization queries
* I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience.
all you need is mvc framework, I offer you take Zend Framework
For 1 month project use what you know better! Until now I have used Qcodo and Qcubed, but you generate your interface only from the database. Any PHP framework uses DSL. I love Python as language but never used. I was looking Ruby On Rails yesterday and it seems pretty nice. RoR has provided a new way to write agile web applications, but now there is grails too. Grails is written in Groovy, runs over the JVM and is dynamic language. The strengh of Grails is that can use any Java code and framework but with the simplicity of a dynamic language. With Grails you can do the same things of Rails and even more.
My advice, use what you know better, meanwhile learn Grails, this is what I am doing now.
Is 1 month
enough for learning with and building
a website in RoR?
Yes.
Writing direct SQL queries is one of
my strengths and I would like to use
it. I heard that RoR is a pain to use
if I am writing SQL queries directly.
Is this true? Or can I just say
execute a query, give me the results
(as a list or dictionary) and then I
will tell you how to render them?
Writing raw sql with Rails is not any more difficult than doing it with PHP. The object returned will be a hash of column-name/value pairs. The only problem may come if you decide to start using ActiveRecord which returns an ActiveRecord object (not a plain hash)
I have heard that RoR does joins in
memory and doesn't use the facilities
offered by the database. Is this
correct?
If you use raw sql, Rails shouldn't interfere with it.
I need to create a website that
displays a lot of Images, videos and
Java applets. Would RoR hinder my
ability to do this?
No.
I am OK using a PHP framework. Is this
a bad idea? If not, which PHP
framework is closest to Rails in terms
of programming convenience.
IDK.
I really like using ActiveRecord, but if you prefer raw sql, Rails can still be worth using. You'll get good url handling, a lot of built-in security, nice MVC architecture, and a nifty templating system, all while writing Ruby, which for many, has been a good experience.
Nice thread - some great comments in here everyone. This has been useful to me.

Categories