Doctrine 2.0 ready for use? - php

I'm working on a small project (some mark tracking software for a school subject department - PHP frontend with a sqlite DB) and have decided to use ORM.
I've taken a look at RedBeanPHP but it seemed a bit too limited for my liking. As such, I've decided to give Doctrine a go.
My only prior experience with ORM is LINQ to SQL in .NET. Anyway, I was wondering if I should get started with Doctrine 2.0 (which is in beta at the moment) or if I should take sometime to learn 1.2.
I'm looking for feedback from those who are comfortable with both, and more importantly, I'd like to know how complete the Doctrine 2.0 documentation is. Is there enough information on the website for somebody new to Doctrine (and quite new to ORM) to get up and running with 2.0 or is the documentation for the new version still quite lacking?

Doctrine 2 is a DataMapper ORM whereas 1.2 is Active Record. I would go with 2.0; the documentation is great

The Doctrine2 documentation is quite good already. I'd start with the reference.
I've been developing with Doctrine2 for a few months now, and have had no issues. I'll be going into production with it soon, and am pretty confident.
2.0's DataMapper pattern is really superior to the 1.2/ActiveRecord model. Very flexible, and possible more performant. If you're starting development today, I think it's very likely the best way to go.

Related

How to upgrade symfony from 1.4 to 2.1? [duplicate]

I've got a huge site that has been written (in a very bad way) in symfony 1.4
now, I've been asked to make some substantial changes to the navigation flow, add some features and so on..
considering the effort, I was wondering if it would be better to take the radical decision to port the entire website to symfony 2.0, but I'm not sure how hard that it could be.
Has anybody ever done this before?
Do you have any suggestion to make for patterns to follow, or tutorials or doc or whatever?
You may wrap your legacy project in a brand new sf2 project, by using this bundle. This way, you'll be able to migrate your project one piece at a time, and new functionalities may be developed with sf2 as soon as you get the wrapper to work.
You may be interested by this post about migrating
Here's how I would go about it:
You need to learn and study some things first:
HTTP fundamentals
PHP namespaces, which are heavily used
Symfony2 documentation
Symfony2 documentation
Symfony2 documentation
PHPUnit documentation
Then when you get the hang of Symfony2, you need to find out what to reuse from your old project:
Models, business logic?
Did you use Doctrine in symfony? If yes, look at how to port your entities to Doctrine2, and learn about the differences. If you used Propel, I would look at switching to Doctrine2 and not use the PropelBundle, atleast until you get used to Symfony2. You can find better documentation and sample code out there for Doctrine2.
You also need to convert your old helpers classes to Symfony2 services.
Views?
Symfony2 uses Twig as templating engine, but you could go with pure PHP.
Controllers?
This should feel somewhat similar to symfony. The flow of Symfony2 matches the HTTP flow, meaning you get a Request object and must reurn a Response object.
It really depends on how well structured our old project is. Symfony2 is an entirely different beast than 1.0-1.4. I would probably not call it a port, but a rewrite - however, if your old project is well structured you could probably reuse quite a bit.
Without actually seeing your code, it's impossible to give a good answer on how hard it would be. It's very much doable, but there is no easy route. Symfony2 is, IMHO, the way of the future for PHP projects and in the end you will get a project that is much easier to maintain and support.

Porting a website from Symfony 1.4 to 2.0

I've got a huge site that has been written (in a very bad way) in symfony 1.4
now, I've been asked to make some substantial changes to the navigation flow, add some features and so on..
considering the effort, I was wondering if it would be better to take the radical decision to port the entire website to symfony 2.0, but I'm not sure how hard that it could be.
Has anybody ever done this before?
Do you have any suggestion to make for patterns to follow, or tutorials or doc or whatever?
You may wrap your legacy project in a brand new sf2 project, by using this bundle. This way, you'll be able to migrate your project one piece at a time, and new functionalities may be developed with sf2 as soon as you get the wrapper to work.
You may be interested by this post about migrating
Here's how I would go about it:
You need to learn and study some things first:
HTTP fundamentals
PHP namespaces, which are heavily used
Symfony2 documentation
Symfony2 documentation
Symfony2 documentation
PHPUnit documentation
Then when you get the hang of Symfony2, you need to find out what to reuse from your old project:
Models, business logic?
Did you use Doctrine in symfony? If yes, look at how to port your entities to Doctrine2, and learn about the differences. If you used Propel, I would look at switching to Doctrine2 and not use the PropelBundle, atleast until you get used to Symfony2. You can find better documentation and sample code out there for Doctrine2.
You also need to convert your old helpers classes to Symfony2 services.
Views?
Symfony2 uses Twig as templating engine, but you could go with pure PHP.
Controllers?
This should feel somewhat similar to symfony. The flow of Symfony2 matches the HTTP flow, meaning you get a Request object and must reurn a Response object.
It really depends on how well structured our old project is. Symfony2 is an entirely different beast than 1.0-1.4. I would probably not call it a port, but a rewrite - however, if your old project is well structured you could probably reuse quite a bit.
Without actually seeing your code, it's impossible to give a good answer on how hard it would be. It's very much doable, but there is no easy route. Symfony2 is, IMHO, the way of the future for PHP projects and in the end you will get a project that is much easier to maintain and support.

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.

Looking for a good PHP framework - definition of "good" to follow

I'm looking for a "good" PHP framework to suit my needs:
well-documented, preferably with a handful of beginner tutorials (majorly, majorly important.. I looked at Kohana and felt like I wouldn't be able to jump in with both feet and learn it)
fairly solid community (either here on Stack Overflow, or on a forum) for questions, etc
stable and time-tested
greatly reduces amount of code/coding (e.g. what jQuery does for JavaScript)
I'm pretty solid at PHP, I'm just looking for something that will help speed up the development process, handle cleansing input from users, simplify database queries, that sort of thing. MVC and OO is nice, but not exactly a requirement for me.
Have you take a look at symfony?
Symfony (version 1 or 2 - doesn't matter) has a great documentation (with a book to guide you building a web, a book showing you how the framework works, and the usual API documentation). Check here for the full documentation of symfony1 and symfony2.
Symfony2 is rather new, so while I can say it's stable (I'm using it and quite sure it is), time-tested-ness (is that a word? :p) is not so good. But if you want a stable and time-tested, you could try symfony1, because it's still supported until 2013.
The symfony community is also great, both the user community and the developers. Stackoverflow also has many good symfony users, and you can check their mailing list and other resources here.
As for reducing amount of code, symfony comes with a lot of standard library, ORM, and many code-generation tool (usually called from command line). So yeah, it save so many code. In symfony1, you can even generate a CRUD application without a single line of code written by you. I know you also can do this in symfony2, but I haven't tried it yet. You can be sure that you will more focused on coding your business logic well than fighting the framework.
Hope this helps.

Starting with Doctrine. Which version is good to?

I'm using Zend Framework and I feel that I need a good ORM to work with. I don't know much of Zend Framework, I just know how to do the basics. I expect to work together with both Doctrine and Zend Framework
But to sget started, I'm going to try a simple Doctrine project (no ZF) to get used to the application. Then I'll try to integrate it in ZF
Which version of Doctrine do I start learning? Does Doctrine have a good integration with ZF?
Besides,
Is there any recent site for Doctrine learning? I just can't find the sandbox version to follow the Doctrine documentation. If anyone knows of any tutorial on how to get started with doctrine only first, please let me know
I've done projects with zend framework and doctrine. They play pretty nice together.
I followed this tutorial and it worked well.
But honestly I don't use doctrine on anything but the largest sites. I've switched over to RedBean. Zero configuration autodiscovery, and the ability to freeze data models when you are done for maximum performance.
You should really try it out, it is so simple its stupid. It is really one of the best ORM's ive ever used. EVER. Try it.
I am personally using Doctrine 1.2
and i followed the Zendcasts.com "more than 5 casts about doctrine" & same Byron's tuts
both of them is good
Update :
1- http://www.zendcasts.com/deep-integration-between-zend-and-doctrine-1-2/2010/01/ has the sample code
2- http://www.doctrine-project.org/projects/orm/1.2/download/1.2.3 has the doctrine framework if you need to download it alone
I've found Doctrine2 reasonable stable, although it's still in beta. It seems most of the other PHP 'ORM' libraries (Doctrine 1.2 included) are Active Record, while Doctrine2 is a Data Mapper. In my opinion, you can put together a relatively simple Active Record using Zend's native Db_Table, so that makes Doctrine 1.2 less appealing (at least to me).
I've used this answer about integrating Doctrine2 and Zend Framework.
I agree with Byron, and have only used Doctrine2 on select projects.
[As an aside, I've noticed RedBean in the past, and have wanted to try it - from what I've seen it's certainly worth taking a look.]
Doctrine 2 is in beta and requires PHP5.3 as it fully utilizes Namespaces. If you cannot use PHP5.3 in your project, you cannot use Doctrine 2.
Apart from that, there has been a number of architectural changes in Doctrine 2 that make it much more attractive than Doctrine < 2, mainly
using DataMapper instead of ActiveRecord
promotes DI over static calls
faster and less memory-intensive
revolves around Entities and DDD
uses "Annotations"
See
http://architects.dzone.com/articles/doctrine-1-doctrine-2
http://www.slideshare.net/jwage/doctrine-2-not-the-same-old-php-orm

Categories