We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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?



26.3k
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.



25.1k

@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.



1.7k
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.9k

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
https://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.9k

ok, i see.