Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon vs Laravel

I'm currently in a debate with some co-workers about which framework to use for our next mid sized buisness application.
I'm trying to evangelize Phalcon and he favors Laravel. One point of contention is the ORM.

He basically says that Larvel:Eleoquent is better than Phalcon:ORM because it can more easily save related records. Here is an excerpt from Laravel...

You will often need to insert new related models. For example, you may wish to insert a new comment for a post. Instead of manually setting the post_id foreign key on the model, you may insert the new comment from its parent Post model directly:

$comment = new Comment(array('message' => 'A new comment.'));
$post = Post::find(1);
$comment = $post->comments()->save($comment);

What can I tell him to show that Phalcon does something similar or better?



15.9k
Accepted
answer
edited Aug '14

In Phalcon:

$comment = new Comment();
$comment->assign(array('message' => 'A new comment.'));

$post = Post::findFirst(1);
$post->comments = $comment;
$post->save();

or

$post = Post::findFirst(1);
$comment = new Comment();
$comment->post = $post;
$comment->save(array('message' => 'A new comment.'));

or

$comment = new Comment();
$comment->setMessage('A new comment.')->post = Post::findFirst(1);
$comment->save();

There may be some shorter (and less readable than Laravel) approach because I am beginner only. Phalcon is first framework in my "career". I don't know others.

Still, if this is the only concern of your colleague, tell him that your post made me 100% sure that Phalcon was the best choice.



17.4k

@conradaek Thanks I didn't know you could do similar things in Phalcon. I'm sure he'll have other concerns, but this is very good to know.

edited Aug '14

Both Laravel and Phalcon are easy to use, but Laravel is one of the slowest PHP framework, just a bit better than Zend. (PHP itself is slow enough.)

And I don't like Blade's syntax, volt is really much easier to read. (of course you can use Twig in Laravel)



1.2k

So should you tell me how to start my first phalcon cms?

Both Laravel and Phalcon are easy to use, but Laravel is one of the slowest PHP framework, just a bit better than Zend. (PHP itself is slow enough.)

And I don't like Blade's syntax, volt is really much easier to read. (of course you can use Twig in Laravel)

the more important question would be - why are you thinking about your framework before you've even started your project?

you would be much better served writing YOUR code devoid of any dependancies what so ever.

If you can leave the decision of which framework you will use until much later on it means you can switch out the framework if you need to.

You can use my CMS for Phalcon - Yona CMS
http://yonacms.com/
It has nice structure and you can easily develop new modules.

So should you tell me how to start my first phalcon cms?



1.2k

ok, i see.