laravel vs symfony
2019年8月16日 11分钟阅读

Laravel vs Symfony in 2022 -为你的项目选择哪个PHP框架?

在web开发中,PHP框架是最常用的解决方案. You can find many PHP frameworks in the market, 但Laravel和Symfony是最受欢迎的这类网站开发者.

要决定这两种方法中哪一种更适合您的项目可能会很困难——它们各有利弊, which you should know before you selected Laravel or Symfony. That is why we decided to prepare a quick comparison between these two, 和 we hope that after reading this article, 对于这些框架中哪一个最适合您,您将不会有任何疑问.

 

Laravel & Symfony – basics information about both frameworks

Laravel 是遵循模型-视图-控制器设计模式的开源框架吗. 它重用不同框架的现有组件来创建一个web应用程序. 它还包含了Yii、CodeIgniter或Ruby on Rails等PHP框架的基本特性. 如果你对Core PHP和Advanced PHP有很好的了解,Laravel对你来说就会变得很容易. 它以简单的编码方法和减少开发时间框架而闻名, which is great for developing a simple PHP application.

Symfony – this framework also bases on open-source PHP projects like Propel, 学说, PHPUnit), 嫩枝, 和迅速梅勒. 尽管事实上, that it has its components like Symfony YAML, Symfony Event Dispatcher, Symfony Dependency Injector, 和 Symfony Templating. 自2005年以来,Symfony崛起为一个越来越可靠和成熟的框架. It is mainly used for complex enterprise projects.

 

相似之处

第一个是最明显的——它们都使用PHP作为编程语言.

他们是 跨平台, 这意味着它们是在多个计算平台上实现的计算机软件.

值得一提的是,这两者都是多用户和多语言的内容. 这两者提供了应用程序的框架、接口模式和文本搜索支持.

 

差异

Despite some similarities connecting these two frameworks, we are definitely able to point out differences too.

Symfony可能被命名为传统的PHP语言——它可以被修改为c#或Java, 当然, 它由独特的、独一无二的元素构成,使它出类拔萃. In 2022 Laravel appeared as the most popular PHP framework. It relies more on magic methods 和 traits. 这使得代码更短,整个框架更容易理解. Symfony是为规模更大或更复杂的项目设计的,包含巨大的功能,并被大量的客户使用. 同时Laravel也涉及到前面提到的MVC设计模式. When it goes for scalability, if you choose Laravel, 您应该意识到编写处理此问题的代码的必要性. Symfony为维护可伸缩性提供了几个平台——这为它赢得了一分.

Templating engine – Symfony supplies 嫩枝, but Laravel provides 刀片, which has a great benefit – you could reusable the code. That option does not exist in 嫩枝.

laravel vs symfony

When choosing a PHP framework, 您应该受项目需求的驱动,并考虑开发人员的偏好. 他们中的一些人可能有很好的理由选择其中一种技术.

 

如果您对数据库支持感兴趣——两者都为数据访问提供对象关系映射. Symfony uses 学说, Laravel – Eloquent.

And last but not least – the speed. 在Laravel中,应用程序的速度与其他PHP应用程序相似. It secures a proper version control system, which helps the migration of applications later. 如果正确实现了Symfony,应用程序的速度就会提高. It adjusts an individual core feature speed, 因此,整个应用程序可以很容易地确定当前需要哪些特性.

 

优点 & Cons of Laravel 和 Symfony – Comparison of PHP frameworks

Laravel

优点:

  • It stays updated with the newest version of PHP features.
  • 它允许通过API集成应用程序和最流行的电子邮件服务.
  • It is also compatible with other third-party platforms 和 libraries.
  • 它有一个 大的生态系统 of additional tools.

缺点:

  • Laravel内置的一些应用可能会更重,以便在移动设备上更快地加载.
  • 更新是不兼容的-它可能,如果你更新Laravel到新版本, you could break the code.

 

Symfony

优点:

  • A significant amount of developers is using Symfony actively. Its community is one of the biggest in the market.
  • Well-known platforms like Drupal, 线上购物, 和 eZ Publish using Symfony, so it is a good recommendation for this framework.
  • Symfony会定期更新,以满足网络开发者的需求.

缺点:

  • 在乞讨中,您可能会发现Symfony比其他PHP框架更难学习.
  • 它依赖于其他技术,因此一些应用程序的加载速度会变慢——缺少原始元素.
  • Because of the need to prebuilt code for multiple uses, it requirements more time for testing, 和, 作为一个结果, the development process is slower.

 

Laravel Symfony
Modularity 和 Scaling

Utilizes MVC-based apps, with a number of pre-built dependencies. 这使得它稍微不那么灵活,但如果你使用的是MVC应用程序,它会更加友好.

Uses reusable components, ensuring more robust modularity. Code is organized better.

模板引擎

默认的模板引擎是Blade,允许代码重用,这是嫩枝无法实现的. Lumen是该框架使用的另一个子框架,这使得它非常适合构建api.

Uses 嫩枝 as its default templating engine.

数据库支持

利用对象关系映射(ORM)通过Eloquent进行数据访问. Laravel支持以下数据库的开箱即用:MySQL, PostgreSQL, SQLite和SQLServer.

利用对象关系映射(ORM)通过学说进行数据访问. Symfony supports the following databases out of the box: Drizzle, MySQL, 甲骨文, PostgreSQL, SAP Sybase SQL Anywhere, SQLite, SQLServer.

Database migrations

Database migrations are manual, but don’t require defining fields.

数据迁移是自动进行的,只需要对模型中的字段进行简单的定义.

数据建模

Requires substantial knowledge of SQL. Eloquent also usually ties your app to the DB schema design, making it much less flexible in that regard.

不需要大量的SQL知识,但是您必须为每个调用创建一个存储库.

 

When is Laravel better than Symfony (和 the other way ground)?

Laravel seems to be perfect for projects when you need to develop your app quickly, 和 you do not want to spend so much money. When you decide to download Laravel, 您将获得许多现成的实现,使工作变得更容易. 但 on the other h和, not every solution will occur useful for you, 和 you might have never used it.

使用这个框架进行授权非常简单——您应该只在迁移过程中配置数据库和模型.

魔术方法 Laravel最大的优点是-你可以避免太复杂和太长的代码. It is saving your time, money 和 mental health of your web developer.

Symfony is an answer for long-term, complex projects. It requires you higher financial outlays, but it returns the favour when you want to personalize your app. New versions of Symfony – for example, Symfony 4只提供给你最必要的东西,并允许你只添加那些你真正需要的元素. This framework consists of – you can make profound changes at the level of bundle, 结果就是, you do have not to change the whole project.

Symfony可以比其他框架更快——它的速度取决于单个元素的速度, so a good selection might be helpful.

Laravel 和 Symphony are both popular 和 trustworthy. As we mentioned before, the crucial thing is to consider what project we want to launch, what features it should have, 和 what goal we want to achieve. 十大靠谱网投平台希望在回答了这些问题并阅读了本文之后,这个艰难的选择变得清晰起来.

 

PHP开发框架 FAQ

What are the advantages of the Laravel Framework?

Laravel has many advantages. 首先,它有一个非常友好的语法和优秀的文档. It is very flexible, easy to scale 和 exp和. 它非常流行——很容易找到开发人员并帮助社区. Quick 和 ready to integrate with the front-end - a big advantage. CLI, LTS cron作业,都是可以使用了.

What are the advantages of Symfony Framework?

Symfony allows everyone to work quickly 和 efficiently. 它有一个 huge amount of reusable components to use in many situations. Laravel的模板系统嫩枝是最受程序员欢迎的系统之一. Symfony允许你调试网络,有一个巨大的社区,插件包. Developers like Symfony because it is user-friendly.

What are the other PHP frameworks?

Laravel 和 Symfony are not the only PHP frameworks. 其他是:Codeigniter, cakePHP, Yii, Zend框架,Phalcon, FuelPHP, PHpixie, Slim.

 

行动呼吁
没有更好或最差的框架——只有适合或不适合您的项目. And we can help you decide which one is better for you!

分享

SUBSCRIBE our NEWSLETTER

Are you interested in news from the world of software development? 订阅十大靠谱网投平台的时事通讯,你会收到一份最有趣的信息列表.

    评论 (6) 评论箭头

    1. 以利亚克鲁兹

      这篇文章中有很多错别字,但不管怎样,都不算太糟! I prefer Laravel because of how fast you can go from design, 为原型, 发展, to production with Laravel, especially as the code is very reusable. In terms of the speed you mentioned for mobile, that can be fixed fairly easily by caching your routes, 的观点, 控制器, 和 models using Artisan. There is about a 23% Difference when doing such, 你也可以查看你的PageSpeed Insights,以更清楚地了解如何让你的网站更快. 只要稍微研究一下,Laravel的PageSpeed很有可能达到95+. The only reason the Symfony seems faster, 是关于如何替换掉你根本不需要的任何组件. Don’t get me wrong, it it still very fast, 和 Laravel even uses a few Symfony components in it’s own framework, but Laravel can still excel in speed. 在Symfony 4, it saw a much larger speed increase, Laravel最终把它的一些组件添加到自己的代码中. Laravel使用Symfony的一个例子主要存在于它的安装程序中, as it uses symfony/console, symfony/filesystem, 和 symfony/process as you can see on the installer’s packagist.

    2. Chris Manuel Fritsche

      我有文件表明这篇文章是由一个叫Laravel的朋友写的. 但, 不管, I would recommend to also make more two mentions: 1- the difference between the ORM’s (Eloquent -> Active Record 和 学说 -> Data Mapper), because this interfere a lot how you build you application. 2- the documentation (Here, without discussion, Laravel is some good steps in front, 和 this can make a big difference, 相信)

    3. Laravel is for pros. Symfony is for experts 😉

      更严肃的一点是:当我在Symfony的7年项目中工作时,我发现很少有问题, except for missing out on new features. 然而,当我在Laravel的老项目中工作时,我忍受了许多挫折.

      可能是巧合,Symfony项目的开发人员比Laravel项目的开发人员做得更好. To my beliefs a big part of the difference lies in the framework:
      Laravel offers Facaded, helpers 和 magic that help you write less code, but also enables you to write code that is bad to maintain. Symfony somewhat enforces their best practises on you, which might feel like you have less freedom, but that’s often just a matter of lack in experience.

      考虑一下这一点:Laravel中更少的代码意味着你必须通过你的大脑去做/知道更多, while in Symfony you can just read the code that is missing in Laravel. 这可能会让你在独自制作游戏时更容易使用Laravel, 但它使Symfony更适合团队工作或长期项目.

      这里是我采用的方法:
      * Laravel对于那些想要获得更多经验的新手来说是更好的选择. It is perfect for student projects, 因为这不是长期的,你不想在学习曲线上浪费太多时间.
      * Symfony是为客户建设项目的公司的更好选择. 这些项目应该是长期的,并且适合作为一个团队进行开发. If you’re absolutely certain that a project is small or short-term, then Laravel might be a better pick, 但就我个人而言,我会坚持使用Symfony:一旦你在Symfony已经有了几个项目, 那么Laravel不会比Symfony更快(至少我肯定不会用Laravel比Symfony更快地构建一个项目)

    4. 威廉·道格拉斯

      我认为嫩枝是可重用的,你可以扩展一个基本模板,并包括另一个片段. It also have a lot of filters, 和 you can override content blocks too.

    5. Another complete non sense comparison. I was a fan of Symfony in past but not anymore. 对于那些认为Laravel更有魔力的人,我想说Symfony更有魔力. You ever wondered how those annotations works. In Laravel everything is in PHP. I know same can be done in Symfony too but it’s way too verbose. Simply put both framework are pro grade.

    6. 我看到有人提到嫩枝不像刀片一样提供可重用性. 但据我所知,嫩枝提供了和Blade模板一样多的可重用性,如果不是更好的话.

      您可以扩展模板,甚至传递变量,使其在维护模块化和可重用性方面非常有用. Drupal非常有效地使用了它,提供了主题层的完全分离.

      Laravel所做的是让初学者更容易上手,并快速创建原型.

      我还是Symfony的新手,应该说,在那里开始是一个艰难的学习曲线. 但 I’ve used Drupal which uses many of the underlying principles & components of symfony. (By the way, Laravel also uses many symfony components). 我喜欢Symfony和Drupal这样的系统的原因是,这样的项目组织得更好,而且提供了模块化. 使用这种系统的主要挑战是,您必须了解其背后的抽象概念. Once you have a grasp of it, it is a joy to work with such systems, if you love creating well engineered products.

      Laravel on the other h和 takes a practical approach. Practical in the sense, 因为它提供了一个简单的学习曲线,并快速将你的初始项目推向市场. 所以,对于新手或自由职业者来说,要想获得自信,Laravel是一个完美的工具. Also, this might be all that is needed for many out there.

      但 inspite of the initial learning curve, 我觉得, the development speed could be more or less the same, 随着您获得经验,并将拥有自己的项目入门套件/模板.

      Those who are passionate about technologies, wants to build on their expertise 和/or grow as a team, 等.,会发现Symfony的吸引力,因为它将帮助您创建更好的可维护的模块化代码.

    添加评论

    相关的 文章

    友情链接: 1 2 3 4 5 6 7 8 9 10