Symfony 2: Useful libraries and bundles

    For about six months now we have been using Symfony 2 to develop web projects. A list of useful libraries and bundles has been accumulated 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:
    • Admin Generators
    • Users
    • Import / Export xls
    • API and OAuth 2.0
    • Menu / Navigation
    • Multimedia
    • Forms
    • Search
    • Pagination
    • File system
    • HTTP client

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


    Admin Generators


    Sonataadminbundle

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

    Using together with:
    • SonataDoctrineORMAdminBundle / SonataDoctrinePhpcrAdminBundle / SonataDoctrineMongoDBAdminBundle / SonataPropelAdminBundle
    • Sonatauserbundle
    • SonataMediaBundle
    • FOSUserBundle

    you can organize a decent “admin panel” that allows you to manage:
    • By users
    • User groups
    • Media (images, videos, YouTube, Vimeo, other files)
    • User Entities and Entity Relationships

    There is:
    • dashboard
    • login / logout
    • menu
    • extensible filters for lists
    • widgets and handlers for relationships between entities (manyToOne, manyToMany, etc.)
    • group operations
    • import lists in json, csv, xml, xls
    • interface translations


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

    Stable with stable Symfony 2.0. *.
    We used with 2.0.10.

    About SonataAdminBundle there was already a vitiko post . Project website Project on github.com Sandbox





    Adminmingrator bundle

    A simpler and less functional package for managing your entities, but with a more convenient (subjective) customization mechanism. The entire configuration is described in generator.yml for each entity.
    There is:
    • menu
    • filters for lists, by entity field values
    • widgets and handlers for relationships between entities (manyToOne, manyToMany, etc.)

    I think it deserves attention, although it requires a lot of manual work and as it seemed a lot of repetitive actions. For each entity, an admin bundle and a bundle had to be generated to display information in the public part.



    Project site
    Project on github.com
    Sandbox
    Vidos



    Users


    FOSUserBundle

    One of the most popular bundles for Symfony 2, which provides extensive functionality for user management. The package implements the main tasks that arise when working with users:
    • Basic user properties: activity, name, login, password, email, date of creation / change / last authorization, etc. Flexible expansion
    • Symfony 2 Role-Based User Groups
    • Registration of users with confirmation by email
    • Password recovery
    • User profile
    • Various forms and handlers
    • Various data storage schemes: DB, NoSQL

    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 Facebook PHP / JavaScript SDK's into your Symfony 2 project. In addition, it provides its own authentication provider, which allows users to log in to the project via Facebook (button, “Login via Facebook”). At the same time, integration with FOSUserBundle is supported.

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

    Project on github.com



    Import / Export xls


    PHPExcel

    Well-known library for working 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

    A 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

    A bundle with useful tools for creating RESTFul web services.

    Opportunities:
    • View helper for rendering the response (Response) in the desired format (json, xml)
    • Custom routes loader for generating resource urls in accordance with the REST concept
    • Automatic route generation (routes) for web service resources by controller method name (getNewsAction () -> / api / news)
    • Exception controller for sending appropriate HTTP statuses

    Very useful when developing the server side of a mobile application.

    Project on github.com

    EscapeWSSEAuthenticationBundle

    A bundle that allows you to organize simple authentication of requests to your API. Based on advanced HTTP authentication. As an extension, the open security specification for web services, WSSE, is used. In particular, adapted for HTTP Authentication, the WSSE Username Token algorithm, borrowed from SOAP.

    Also useful when developing the server side of a mobile application.

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

    OAuth2-PHP

    OAuth 2.0 server in PHP. OAuth 2.0 draft 20 is currently being implemented.

    Project on Google Code
    Project on github.com (fork)

    FOSOAuthServerBundle

    A bundle integrating OAuth2-PHP features into a Symfony 2 project.

    Useful for projects who want to implement access and authorization to their own API using the OAuth 2.0 protocol.

    I didn’t use it in real projects, but when testing it seemed that it was well implemented (If anyone has experience in battle, please 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 bundles for Symfony 2, which integrates the KnpMenu library into your project and provides various tools for flexible management of site navigation (menu):
    • Object-oriented interface for creating menus of various nesting and complexity, including based on data from the database
    • Rendering menus according to custom templates
    • Twig features
    • Highlighting active items and various customization tools

    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:
    • Gd2
    • Imagick
    • Gmagick

    Opportunities:
    • Resize, crop images
    • Drawing API, for creating an image and drawing text on an image
    • Functionality of masks for working with image transparency
    • Creating various filters based on the above features

    A very convenient library for creating thumbnails, but this is only a small part of all the features.

    On creation, the author was inspired by the PIL library in Python.

    Project site and API
    Project on github.com

    AvalancheImagineBundle

    A bundle for easily manipulating images in your Symfony 2 project.
    Allows you to configure various filters to display images from your collection.
    Filter Settings:
    • Thumbnail size
    • Compression ratio
    • Resize / crop method (outbound / inset)
    • Image Processing Driver (gd, imagick, gmagick)
    • and other

    There are Twig tags (functions) for displaying the corresponding image with the selected filter. The bundle also has a custom route loader. When accessing a specific controller, it (the controller) generates an image and gives it as a server response.

    Used this bundle to dynamically generate thumbnails:
    • Original images are uploaded to the site gallery
    • Required filters are configured.
    • In the views, the paths to the images corresponding to the settings of the bundle and filters are displayed (using the twig function)
    • When a client contacts the server for an image, we make apache / nginx check the actual existence of the image
    • If the picture exists, the server gives it as a static
    • If not, it does rewrite / redirect to the corresponding controller, after which the image is created and subsequently given statically

    It was true that I had to create my Twig extension, with the function generating the path to the picture, taking into account the specified filter, the bundle settings and my requirements.

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

    Project on github.com

    SonataMediaBundle

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

    Each type is managed by its service provider, which is responsible for:
    • Extract media file metadata
    • Create image thumbnails
    • Edit Form Settings
    • Rendering and presentation of media files in templates

    Media files can be context related. Context allows you to group media sets, 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:
    • Thumbnail size
    • Compression ratio
    • Resize / crop method (outbound / inset)
    • Other


    The package provides the ability to implement its resize and crop logic for its filters, as well as an alternative to LiipImagineBundle (fork AvalancheImagineBundle).



    Available Services:
    • Providers:
      • sonata.media.provider.image: Image
      • sonata.media.provider.file: File
      • sonata.media.provider.dailymotion: Dailymotion
      • sonata.media.provider.vimeo: Vimeo
      • sonata.media.provider.youtube: Youtube
    • File systems:
      • sonata.media.filesystem.local: Local file system (default)
      • sonata.media.filesystem.ftp: FTP
      • sonata.media.filesystem.s3: Amazon S3
    • Various CDN

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

    Project website
    Project on github.com



    Forms


    GenemuFormBundle

    A bundle extending the functionality of Symfony 2 Form Component, using jQuery, jQuery UI and various plugins.

    Some of the form types and widgets that the bundle provides are:

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

    Project on github.com

    Captcha bundle

    The bundle adds captcha support for the Symfony 2 Form Component.
    It contains a basic set of settings, but if desired, you can add / change the required functionality:
    • Background color
    • Text color
    • Font
    • Font size
    • Distortions

    I really needed to be very fast, so I had to fix the bundles, but next time I will do PR, honestly)))

    Project on github.com



    Search


    Sphinx bundle

    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 will need the sphinxapi.php library from the official site .

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

    Although the bundle does not provide many opportunities, it helped me a lot as a base for implementing my tasks. For example, I had to implement my logic to work with several entities (the sphinx index should also be built on several entity tables), so that later in the view for each entity we would use personal “search snippets” (text blocks that differ for each entities) and routes for generating links, because entities were represented in different sections of the site.

    Project on github.com



    Pagination


    Pagerfanta

    Library for "pagination" of data sets, on PHP 5.3.

    It uses various adapter classes, depending on the types of data that you want to paginate:
    • Arrayadapter
    • Mongoadapter
    • Mandangoadapter
    • DoctrineORMAdapter
    • DoctrineODMMongoDBAdapter
    • DoctrineCollectionAdapter
    • Propeladapter
    • SolariumAdapter

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

    Github project

    WhiteOctoberPagerfantaBundle

    A bundle that allows you to quickly and easily integrate the Pagerfanta library into your Symfony 2 project. 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 nevertheless a solution was found and a custom adapter was written for queries built using NativeQuery. Now it seems to be fixed, but only for Doctrine ORM 2.2 (if I understood this commit correctly )

    The project on github.com



    Файловая система


    Gaufrette

    A library that provides a level of abstraction of the file system, and allowing 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 the space for files, you can simply change the file system used 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 the SonataMediaBundle.

    Had 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 in PHP5.3. Allows you to send HTTP requests (using FileGetContents, Curl, MultiCurl), receive responses, work with Cookies, HTTP headers, send forms, work with request history and more.

    I think there will be an application)

    Project on github.com

    SensioBuzzBundle

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

    Project on github.com



    Fuuuh! That's
    all for now ...

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

    Also popular now: