开发者

Sensiolabs/Symfony duplicated components: Which ones should I use?

开发者 https://www.devze.com 2023-04-11 06:48 出处:网络
Pimple or Container? http://pimple.sensiolabs.org/ http://components.symfony-project.org/dependency-injection/

Pimple or Container?

http://pimple.sensiolabs.org/

http://components.symfony-project.org/dependency-injection/

Twig or Template?

http://twig.sensiolabs.org/

http://components.symfony-project.org/templating/

I'm not asking for an opinion, I just want to know this:

  • Why are these components being distributed with different names?
  • Which ones are newer?
  • Which are the ones being used by symfony 2 ?
  • Is there a list for components like Pimple and Twig? Like there is for Container and Template: http://components.symfony-project.org/
  • 开发者_运维百科


There are 3 categories of projects you have listed.

  1. Third-party library. While provided by sensiolabs, these are standalone libraries not under the symfony namespace.

  2. Old Symfony 1.x components, also standalone but under the Symfony namespace. Available at components.symfony-project.org, compatible with PHP 5.2.

  3. Symfony2 components, part of the Symfony2 package, but can also be used standalone. Compatible with PHP 5.3+.

Ok, so let's categorize the projects you've listed.

Category 1

  • Pimple
  • Twig

There is currently no Pimple bundle for Symfony2. The recommended way to go with is to use the Symfony2 DependencyInjection component, which ships with the framework.

Note: Pimple is heavily used by Silex, so if you like Pimple, you might want to take a look at it. It's a different framework that is based on Symfony2 components.

Twig, on the other hand, is supported very well by the Symfony2 core framework. There is a core Bundle for it, and most of the documentation suggests you use it. It is definitely the recommended way to do templating in Symfony2.

For a list of more of these, take a look at Fabien Potencier's GitHub profile. IMO the important ones are: Twig, Silex, Pimple, Goutte, (Pirum, Sismo).

Category 2

  • Symfony Components DependencyInjection
  • Symfony Components Templating

These are old and should no longer be used.

Category 3

  • Symfony2 DependencyInjection Component
  • Symfony2 Templating Component
  • Symfony2 Twig Bundle

These are all part of the Symfony2 framework, and you should use them. They are the latest and greatest.

Hope that answers your questions!


I think that you could use http://components.symfony-project.org components if you have some kind of legacy project that uses php 5.2 or your server has php older than 5.3.

I have a project, I' m doing some rewriting, but it's legacy php 5.2 so I decited to use the old components (http://components.symfony-project.org) instead of new symfony's 2.0 components

0

精彩评论

暂无评论...
验证码 换一张
取 消