📜 ⬆️ ⬇️

Symfony 2: Useful Libraries and Bands

For about six months we have been using Symfony 2 for developing web projects. We have accumulated a list of useful libraries and bundles that are not part of the symfony-standard , but significantly save time and save the invention of the bicycle.



The review is more theoretical and includes the following sections:

Examples of use and code can be studied on the pages of each project on github.com or on official sites, but if interested, some solutions can be considered separately.
')

Adm generators


SonataAdminBundle

Probably the most functional package for creating a content control panel.

Using together with:

You can organize a tolerable "admin", allowing you to manage:

There is:


For database abstraction and NoSQL are available: Doctrine, Propel.

Stable running with stable symfony 2.0. *.
We used with 2.0.10.

About SonataAdminBundle was already post vitiko .

Project site
Project on github.com
Sandbox

AdmingeneratorBundle

A simpler and less functional package for managing your entities, but with a more convenient (subjectively) customization mechanism. The entire configuration is described in generator.yml for each entity.
There is:

I think it deserves attention, although it requires a lot of manual work and how many repetitive actions seemed. For each entity, it was necessary to generate an admin bandle and bundle to display information in the public section.



Project site
Project on github.com
Sandbox
Vidos



Users


FOSUserBundle

One of the most popular bundles for symfony 2, which provides extensive functionality for managing users. The package implements the main tasks that arise when working with users:

Used in many other projects for symfony 2.

Project on github.com
Video manual

SonataUserBundle

Used to integrate the FOSUserBundle into the SonataAdminBundle, manage users through the administrative interface, and extend the functionality of the FOSUserBundle.

Project on github.com

FOSFacebookBundle

This bundle integrates the Facebook PHP / JavaScript SDK's into your project on Symfony 2. In addition, it provides its own authentication provider that allows users to log in to the project through Facebook (button, “Login via Facebook”). At the same time, integration with FOSUserBundle is supported.

You can use Symfony 2-based Canvas App for Facebook, but you will need to write your AuthenticationListener for cross-browser sessions (p3p and blocking iframe cookies from ie7 / 8).

Project on github.com



Xls import / export


PHPExcel

Everyone knows the library to work with xls tables.

It is convenient to use to import data (customers like to provide data in xls) to the database and export to xls (statistics, reports, etc.)

Project site and documentation
Project on github.com (unofficial repo)

ExcelBundle

Bundle providing various service containers (DI) for working with PHPExcel. Allows you to quickly create controllers that generate xls as a response (Response).

Project on github.com



API and OAuth 2.0


FOSRestBundle

Bundle with useful tools for creating RESTFul web services.

Opportunities:

Very useful in the development of the server side of the mobile application.

Project on github.com

EscapeWSSEAuthenticationBundle

Bundle allows you to organize simple authentication of requests to your API. Based on extended HTTP authentication. The extension uses open security specification for web services - WSSE. In particular, adapted by HTTP Authentication, the WSSE Username Token algorithm, borrowed from SOAP.

Also useful in the development of the server side of the mobile application.

Atom Authentication
Project on github.com
Information on symfony.com

OAuth2-php

OAuth 2.0 server in PHP. Currently implemented OAuth 2.0 draft 20.

Google Code Project
Project on github.com (fork)

FOSOAuthServerBundle

Bundle integrates OAuth2-PHP features into a symfony 2 project.

It is useful for projects wishing to implement access and authorization to their own API via OAuth 2.0 protocol.

In real projects I did not use it, but when testing it seemed that it was well implemented (If someone has experience in combat, write in the comments).

Project on github.com



Menu / Navigation


Knpmenu

A library that provides an object-oriented interface for creating navigation on your site.

Project on github.com

KnpMenuBundle

Also one of the most popular symfony 2 bundles that integrates the KnpMenu library into your project and provides various tools for flexible navigation management (menu) of the site:

Used in all projects.

Project on github.com



Multimedia


Imagine

Library for working with images in the usual object-oriented style. Depending on the selected image, you may need:

Opportunities:

Very handy library for creating thumbnails, but this is only a small part of all the possibilities.

The author was inspired by the PIL library in Python.

Project site and API
Project on github.com

AvalancheImagineBundle

A bundle for simple image manipulation in your symfony 2 project.
Allows you to customize various filters for displaying images from your collection.
Filter Settings:

There are Twig tags (functions) to display the corresponding image with the selected filter. Also in the bundle implemented custom route loader. When accessing a specific controller, it (the controller) generates an image and gives it as a server response.

I used this bundle to dynamically generate thumbnails:

I had to really create my own Twig extension, with the function that generates the path to the picture, taking into account the specified filter, bundle settings and its requirements.

Conveniently! Alternatively, you can use for the server part of mobile applications, when changing the design of the concept, it will be enough to describe the new filter.

Project on github.com

SonataMediaBundle

A media library that allows you to manage (load, delete, organize into galleries) various media (files, videos, images) in your Symfony 2 + SonataAdminBundle project.

Each type is managed by its own service provider, which is responsible for:

Media files can be context related. Context allows you to group sets of media, for example: news - news context, users - user context. Since the requirements for media files can be different for each context, the context determines the filters (configured in the config) that will be used to change the media.

Filter Settings:


The package provides the ability to implement its own logic of resizing and framing for its filters, as well as an alternative to LiipImagineBundle (fork AvalancheImagineBundle).



Available services:

In general, a powerful package, but there are a number of small jambs, which have to be fixed when using. For example, displaying a preview of a picture when editing an entity using media binding.

Project site
Project on github.com



Forms


GenemuFormBundle

Bundle extending the functionality of the Symfony 2 Form Component, using jQuery, jQuery UI and various plug-ins.

Some forms and widgets that the bundle provides:

It is unlikely that you will need to use all the features in one project, but tweaking some implementations will be useful and can save time.

Project on github.com

CaptchaBundle

Bundle adds captcha support for the symfony 2 Form Component.
It contains a basic set of settings, but if you wish, you can add / change the required functionality:

I really needed to be very fast, so I had to fix the bundle, but next time I’ll do PR, honestly)))

Project on github.com



Search


SphinxBundle

I think you should not tell what Sphinx is, everyone should know. So SphinxBundle is a bundle that allows you to work with Sphinx search indexes. To work, you need a library sphinxapi.php from the official site .

In the index, according to the table of the entity (Entity on which the search is performed), there must be an identifier (id) of each entity. After a request to the search daemon, by identifiers (id) of the found records, the entities themselves that are relevant to the search query are obtained from the database, with the possibility of page-by-page navigation.

Although the bundle doesn’t provide so many opportunities, it helped me a lot as a base for realizing my tasks. For example, I had to implement my own logic for working with several entities (the sphinx index, also has to be built on several tables of entities), so that later in the view (View) for each entity use personal “search snippets” (text blocks that differ for each entities) and routes (route) for generating links, because entities presented in different sections of the site.

Project on github.com



Pagination


Pagerfanta

Library for "pagination" of data sets in PHP 5.3.

Uses different adapter classes, depending on the types of data that need to be paginated:

It is possible to control (View) a pager, several ready-made options, as well as the possibility of versatile customization.

Project on github

WhiteOctoberPagerfantaBundle

A bundle that allows you to quickly and easily integrate the Pagerfanta library into your project on Symfony 2. And also use additional features such as: Twig functions, custom templates, and others.

Used in almost all projects. There was a problem with the DoctrineORMAdapter when paginating the Doctrine \ ORM \ NativeQuery object, but still a solution was found and for custom queries built using NativeQuery a custom adapter was written. Now it seems to be fixed, but only for Doctrine ORM 2.2 (if I understood this commit correctly)

Project on github.com



File system


Gaufrette

A library that provides a level of file system abstraction, and allows you to develop applications that involve the use of a large number of media files, without thinking about where and how they will be stored.

Using abstraction in this case gives you the opportunity to change the storage location of your files, without much intervention in the code. Suppose your project has become popular, and there is a problem with file space, you can simply change the used file system from local to Amazon S3 file hosting and scale your media data further without any problems. And to speed up the work of slow file systems (Amazon S3, FTP), a local caching mechanism is provided.

This library provides a file system abstraction layer for SonataMediaBundle.

It was possible to use only with the local file system, it is interesting to hear the comments of those who used with FTP or Amazon S3.

Project on github.com



HTTP client


Buzz

HTTP client on PHP5.3. Allows you to send HTTP requests (using FileGetContents, Curl, MultiCurl), receive responses, work with cookies, HTTP headers, send forms, work with the history of requests and more.

I think there is a use)

Project on github.com

SensioBuzzBundle

Bundle integrates the Buzz library into your project on Symfony 2 as a container service (DI).

Project on github.com



Fuuuh!
While all ...

And yes, it is convenient to use knpbundles.com to search for bundles .

Source: https://habr.com/ru/post/142541/


All Articles