Hacker News new | past | comments | ask | show | jobs | submit login

It's interesting that he names Symfony 4 as one of the main reasons he uses PHP again after he already used PHP with Laravel.

I have a lot of discussions with friends in the startup scene about the topic of Laravel vs Symfony. So far it's a head to head race.

I have yet to find a good 'Laravel vs Symfony' comparison page. Yes, there are tons of 'SEO optimized articles' with this title. But I find them all rather uninformative and often even totally wrong and unfair.

The page I would love to see would have the same project coded twice. Once with each framework. And then display each file on the left for Laravel and the corresponding file on the right for Symfony.




Those SEO pages are horrible. I had the same problem.

But there are multiple reasons I choose Symfony 4 over Laravel.

And if you want a code comparison then this small example:

Laravel:

  class User
  {
  }
Symfony:

  class User
  {
    private $id;
    private $name;

    public function getId():?int
    {
       return $this->id;
    }

    public function setName(string $name): self
    {
      $this->name = $name;

      return $this;
    }

    public function getName():?string
    {
       return $this->name;
    }   
  }
Laravel looks a lot easier and quicker. And it is. But good luck next month when you can't remember what properties User has. Your IDE can't autocomplete it. And also good luck working with a team. Your team members have to look up the database model for the User to see what properties are available.

And this is happening in Laravel all the time. Very quick, very easy, a lot of magic but it will bite you in the end.


I don't use laravel anymore, but I had a live template that would generate getters and setters that wrote to set_attribute. As long as you maintained the convention of doing this, you could use autocomplete with getters and setters to accomplish this.

You could also hint these with / @var */ there are ways around it but yes it isn't ideal. I really liked doctrine, perhaps I was using it wrong, but having everything in annotations was pretty nice since migrations etc could run off of it.

With doctrine I ran into issues with performance, which you can alleviate with extra lazy etc, it also hydrated what appeared to be massive objects, which you had to use a custom debugger because print_r'ing one with the recursive references etc caused some crazy issues. I have since moved on from PHP, but if the project calls for it, I have no problem using laravel. While not ideal, it sure is productive to build an API in. I wrote a project in lumen, which is/was a subset of laravel built for APIs, and that was okay to work in. No clue if it still exists.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: