Is there a framework for data access in PHP? - php

I'm a .net developer by trade but I'm looking to expand to PHP. I really like what I've seen PHP can do. However I have been somewhat spoiled with data access in .net (such as LINQ) and how easy it is to make strongly type datasets. Are there such ways to do the same (or similar ) thinks for data access in PHP? A framework I'm unaware of perhaps?
I'm currently planning using a PHP Framework such as CodeIgnitor, jQuery for JavaScript, and possibly a CSS Framework for my next project. I'm very excited to learn something new but when I think of data access in PHP I hit a wall.
Thanks for your input!

I am also a .NET Developer spoiled with LINQ, I've been using CodeIgniter for a small project and I've been very pleased.
You can take a look at Active Record on Code Igniter
http://codeigniter.com/user_guide/database/active_record.html

Most frameworks you come across are going to have some kind of data pattern - DAO, Active Record, etc. So that should suit your needs if you plan on adopting one from the start.
I am not entirely familiar with .NET and LINQ. But PHP does have some native DB libraries as well as PEAR libraries (PDO) that serve as good wrappers.

Pattern and Practice yourself with MVC for PHP ... this will give you the closest adaptation to ASP.NET C# DataSet - Also, be wary of the classes/object handling in PHP as they are definately not the same.

The Doctrine ORM is hugely popular, and is integrated my favorite PHP framework Symfony.

PHP doesn't have the same kind of type safety that you've come to enjoy with .NET -- and there is not, as far as I know of, anything that works quite like LINQ available for PHP (a little searching pointed me to PHPLINQ, but it doesn't do everything LINQ does). There are however, several good ORMs available for PHP that will give you object-oriented access to your database tables.

http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#PHP

Axon ORM is bundled with the PHP Fat-Free Framework.

Related

Solutions to build a lightweight and heavily database-driven website?

I'm looking for some kind of CMS or framework + ORM (I don't really know exactly what I'm looking for).
My goal is to build a web app to view and manage database records.
To help understand, I would like some sort of end-user phpmyadmin/CMS hybrid with minimal programming efforts. In fact, that is to build a database of a particular kind of products, where those are submitted and consulted by end user and validated by myself.
I first thought that wordpress + plugins, mediawiki + semantic or drupal could be quick solutions but
those are quite heavy for the purpose.
Playing with tons of plugins don't reassure me, as they can become unmaintained, conflicting, ..
Solutions like mediawiki requires bunch of time to write templates, etc..
Then I thought at using a framework (let's say symfony) but it's also very time-consuming (compared to an almost out-of-the-box solution).
Finaly, I thought that the quickest solution may be to develop it all by myself using an easy ORM (like RedBean), but I wish I could find a quicker solution.
Any idea ?
Note: I intend to use a php/mysql solution.
There are plenty of "micro-frameworks" for PHP that work very well with RedBean (which I love btw). It's a compromise between writing everything from scratch and using a full blown framework. I find their is a good degree of flexability using these small(ish) tool kits.
One I've used a little bit is Slim, which gives you routing and some other small things a controller would.
Other similar "micro-frameworks" like Slim:
Silex
Limonade
GluePHP (which is about 30 lines of code)
These all give you routing and some other neat tools. In regards to MVC, they sorta give you the C.
If RedBean is your Model, or the M, all your missing is the V, should you want the whole MVC organization.
For that you can use Smarty, Twig or Mustache, or any other templating tool.
I personally love working with these components separately, because I find that they are all highly specialized, integrate nicely, and allow me to control to what extent they are in charge of things. The downside is is that they may have compatibility issues with each other and that you have to maintain three, as oppose to one, third-party library to update and depend on their development.
Here's a good article on using Slim with Idiorm (an ORM) and Twig, though I find Idiorm rather nasty to work with.
Sounds like you could use:
asp.net + mvc or django
Sorry these are two different comparable environments that should help with not a lot of overhead on learning, and can function quite well with mysql

DAL generator for php

Going from .Net to PHP because I want to explore the possibilities of the language I'm struggling to find some way to autogenerate a DAL. In .Net I'd just use visual studio to generate a datamodel, but how can I do that with PHP and MySQL, so I won't have to hand-type in all the classes? My current PHP IDE is Aptana.
You could use an ORM like Doctrine or Propel.
These feature autogeneration of classes from schema, and vice versa.
If you need to write your own access layer, I would reccomend using PHP Data Objects (PDO) as it provides a nice OO interface, and DB engine abstraction.
Normally I wouldn't write an answer, since you have 2 already, but I'd like to give you some insights of my own, giving the fact that Im a .NET and PHP developer and try to take advantge of both:
If you are looking for code generation powerful as Visual Studio, then look no more because in PHP I haven't found one yet and I've been looking for years. Visual Studio is just "huge"
To my understanding there is not such thing as .NET code style. I believe that most PHP frameworks / applications sacrifice much in the sake of "simplicity" and I think is just not right. Code should be extensible, maintainable and scalable in any framework/application you buid
Propel and Doctrine are outstanding for data mapping (ORM), much as NHibernate or Entity Framework in PHP, but remeber that you'll need a Data Access Layer and a Business Access Layer for a fully developed application to be scalable.
Keep in mind that PHP supports OO much like .NET, but differs in a few things, but well develop designs are meant for ANY language.
I think my answer has gone a bit away from the original question, but I liked to give you a bigger answer, since like you said, you wanted to:
...explore the possibilities of the
language...
And you need many opinions to form your own. Best of luck in you endevours and hope that my answer hasn't killed you of boredom! :)
PS: Should you like some more stuff on BLL and DAL using PHP, check out this article I wrote in my blog.
If you really want to jump into the idea behind PHP, and not just write .net style code in PHP, you need to move away from the Objects-all-over methods of .net.
As you've noticed, auto-generation of objects isn't common in PHP. Which means that the solution to the problem should not rely on this.
Try creating more generic objects and taking advantage of inheritance to avoid object bloat. And more-over try to rely less on data transfer objects and more on creating complete object-as-tool objects.
You'll find PHP to be much more of a joy to work with if you escape from the trappings of .net.
To put that in perspective, I don't think in the 5 years I have done work in PHP professionally, on big-scale projects like army.mil, have I ever felt the need to create a full-on DAL to get the job done.
The biggest project I've worked on just has a system of model classes each of which carry a list of methods that poll the database for raw data and then pass that data into the final objects. (in this case articles that make up the articles on army.mil)
There simply isn't a need for another layer between the model and the data in PHP. It almost always just means more work for no gain.
There are various reasons why they DO make sense in .net. Not the least of which being that they can be auto-generated trivially and therefore there is almost no time cost in having them.
That said, when encapsulated within the confines of a framework, DAL begins to make sense again. If your project is basic, I would suggest a framework like CodeIgniter. CI contains a really nice database abstraction system. It forgoes SQL in favor of methods that transform into whatever the particular database you've define in the configuration need. This serves the same purpose as a DAL. You are still creating the query in the model, and you still need to be aware of the structure of your database. But despite what .net want's you to believe, those are really still concerns for .net DALs anyway.
However, to really GET what PHP is all about, you need to lose the trappings of a framework and work freely. PHP is a hacker language. It affords hacking. (as in seat-of-your-pants programming, not cracking, ok, both..) And that is really what you need to do to understand what the fuss is about.
Is it a double-edged sword? Totally. But playing fast-and-loose with code is where PHP comes into its own. There is a reason it is the goto language for speedy up-over-night startups.
Sorry for the long and technically off-topic answer. I hope you can forgive me. You said you have started to use PHP to understand the possibilities of it. If you keep going this way - you'll decide it is weak, inaccurate, clumsy, and prone to errors; and you'll miss all the greatness that it offers in its flexibility, extensibility, hack-ability, and spirit. I don't want you to miss the point of the language.

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.

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