📜 ⬆️ ⬇️

Overview of application frameworks on symfony2

When developing web applications, almost always we want to start with some kind of ready-made base and fasten the necessary functionality with convenience for the developer. Especially for a novice developer it is useful to look at finished projects. Framework, in particular, Symfony2, provides a lot of tools to make application development enjoyable. But among the many bundles (modules of symfony2 applications) it is hard to understand which set to choose.

Each company that has some development experience on Symfony2, most likely has its minimum framework for starting, but in the article we will look at the options that are publicly available.

The article is suitable for readers who are just starting to get acquainted with Symfony2. And people who actively use this framework, I ask to share comments.

Each demo will be described in the following format:
  1. Title
  2. Description
  3. Installation
  4. Basic bundles
  5. Encountering scan problems

Content




Symfony standard edition


Description


The symfony2 application that is provided by the symfony2 community as an example application. In order for the development to be comfortable and fast, in any case, you will need to search and add more bundles (depending on the pursued goal). The framework is suitable for familiarization with the core of the framework, the structure of the application.
')
AppBundle was created in which you can start working (although the bundle structure is easy to generate using php ./app/console generate: bundle). Twig is used as a template engine (can be replaced with another). Doctrine ORM / DBAL and Doctrine PHPCR-ODM are used, Swiftmailer is configured, annotations are included.

Installation


Composercomposer create-project symfony / framework-standard-edition my_project_name
Symfonysymfony new my_project_name

Basic bundles


Table with titles and short description
FrameworkBundlethe foundation
SensioFrameworkExtraBundleadds a few annotations that can significantly simplify the controllers, to the point that all the logic of the controller will be recorded in the annotations.
DoctrineBundledoctrine dbal & orm support
TwigBundlesupport for template engine and some extensions
SecuritybundleThe general principles of operation are chewed by pluseg in the article Symfony2 \ SecurityBundle
AsseticBundlemanagement js, css, pictures, icons
SensioGeneratorBundleadds commands to generate code
WebProfilerBundledebug panel in development and test environments
SensioDistributionBundlecomposer hooks, web configurator, security checker. Used in development and test environments (dev / test)
SwiftmailerBundlesupport library to send letters
MonologBundleMonolog library support for logging


Encountering scan problems


Not found.

Symfony CMF


Description


The meaning of the assembly is to make it easy for the developer to add CMS functionality to the application. The basic principles for existing bundles: scalability, convenience, good documentation and good test coverage. The idea of ​​a loosely coupled CMS (decoupling CMS decoupledcms.org ) is being implemented .

Detailed analysis can be found at the link “Symfony CMF. Part 2 and the last “ by waitekk .

Installation


Composer$ composer create-project symfony-cmf / standard-edition
$ composer install
Git$ git clone git: //github.com/symfony-cmf/standard-edition.git <path-to-install>
$ cd <path-to-install>
$ composer install

Basic bundles


Table with titles and short description
Blockbundleintegrates PHPCR with SonataBlockBundle
CoreBundleprovides common helper methods for displaying content
ContentBundleprovides base classes for defining content, for example, the basis of each document is the StaticContent class, which contains the name, body, publication information, and a link to the parent document to maintain a hierarchical structure of type PHPCR
CreateBundleintegration of create.js - a functional web interface for editing pages using RDFa annotations. In short, it allows you to edit certain elements of the page directly on the published page, without going to the administrative part of the site.
MediabundleAllows you to organize the management of media files from images and binary documents (as pdf) to video and mp3. But it requires some extra effort, because in the bundle control is implemented only for images and files.
MenuBundleintegrates PHPCR with KnpMenuBundle
RoutingBundleexpands the capabilities of the router, allows you to create controllers for redirections and create routes depending on the location of the document in PHPCR
SearchBundleSite search
SeoBundleRalled as an add-on over the SonataSeoBundle
SimpleCmsBundleAllows you to display content, routes, menu items that form a tree in PHPCR
SonataDoctrinePhpcrAdminBundle
integration of SonataAdminBundle with PHPCR



Encountering scan problems


Not found.

REST API


Description


Step by step construction presented in the tutorial .

REST API is not easy to build. This section provides an example of an application with a built REST API.
Implemented example api to blog. The request handler and its interface are rendered into separate classes, the model is represented as an interface from getters and setters implemented by the Page entity. Sharing class responsibility allows you to write better code.

To configure security, you need an additional layer, for example, a bundle that allows you to use Oauth2 ( HWIOAuthBundle ).

The LINK / UNLINK implementation is difficult to remember.

The PATCH method can be varied ( some recommendations ).

Installation


Composer$ curl -s getcomposer.org/installer | php
$ php composer.phar create-project liuggio / symfony2-rest-api-the-best-2013-way -sdev
$ cd blog-rest-symfony2
GitGit clone github.com/liuggio/symfony2-rest-api-the-best-2013-way.git

Basic bundles


In addition to the base in the form of Symfony Standard Edition
Table with titles and short description
FOSRestBundlecreates all necessary configuration routes (YAML or XML) and maps to appropriate methods
JMSSerializerBundleneeded to serialize responses in json, xml
NelmioApiDocBundleDocumentation generation for all API methods is recorded as annotations.


Encountering scan problems


Not found.

Evercodelab skeleton


Description


Application framework prepared and used by Evercode.
One of the features is a customized deployment configuration file (capifony) and there are HipChat connection settings for notifying you of the deployment status and sending log messages about critical errors.

[ Source ]

Installation


Composercomposer.phar create-project evercode / symfony-skeleton path / dev-master
Gitgit clone git@github.com: EvercodeLab / symfony-skeleton.git path /

Basic bundles


Table with titles and short description
GedmoDoctrineExtensionsDoctrine empowerment. Adds such necessary things as Timestampable to automatically set dates when adding and updating records in the database, as well as Tree for the ability to work with trees.
DoctrineFixturesBundlework with fixtures for the database. It greatly simplifies life at the development stage, when it is necessary to constantly generate some kind of test information.
DoctrineMigrationsBudnlegenerates migrations based on database differences from entity mapping. Perhaps the most necessary and important bandl, without which the development would be much more difficult.
FosUserBundleprovides a complete set of functionality for working with users: registration, authorization, etc. in the same spirit.
SonataAdminBundlegives the functionality to create the administrative part of the site: the creation of basic bundles, editing, deleting data, as well as various additional features, such as exporting data to various formats. By itself, this bundle has quite flexible options for customization and customization to fit your needs.
KnpMenuBundlebundle and library for dynamic menu generation. As ways uses routes.
KnpPaginatorBundlecreates dynamic pagination for the site.
FOSRestBundleThis bundle provides a set of tools for the rapid development of the RESTful API and applications.
VichUploaderBundlegreatly facilitates the loading and subsequent use of downloaded files
AvalancheImagineBundle - deprecated, it is better to use LiipImagineBundlecaching, resizing and other necessary operations on images. Most often used to create previews for photos
EvercodePageBundle
A small bundle for working with content pages. Works with SonataAdminBundle



Encountering scan problems


When using capifony you may need to correct:


Sonata sandbox


Description


To demonstrate the work of the sonata project bundles, such a web application was created - a store with rich functionality.

It can significantly simplify the solution of many typical tasks (page layout, creating admin and other CMS functionality, managing media files, etc.), but it requires a significant investment of time, because the documentation could be better.

Installation


Composer$ curl -s getcomposer.org/installer | php
$ php composer.phar create-project sonata-project / sandbox: 2.3.x-dev
or
$ DATABASE_NAME = sonata DATABASE_USER = root DATABASE_PASSWORD = "" php composer.phar create-project sonata-project / sandbox: dev-2.4-develop
Archive$ curl -L github.com/sonata-project/sandbox-build/archive/2.3.tar.gz | tar xzv
$ cp app / config / parameters.yml.dist app / config / parameters.yml
DB Configuration
$ vim app / config / parameters.yml
data loading
$ php bin / load_data.php

Basic bundles


A large number of bundles, and many of them are auxiliary (dependencies), so I cite only the most interesting from the point of view of creating the ultimate functionality.

Table with titles and short description
KnpGaufretteBundlebundle, provides a level of abstraction over the file system, allows you to access files equally regardless of storage (AWS, CloudStorage, ...). If the underlying file system is slow it may still cache access to the files.
DoctrineFixturesBundlework with fixtures for the database. It greatly simplifies life at the development stage, when it is necessary to constantly generate some kind of test information.
DoctrineMigrationsBudnlegenerates migrations based on database differences from entity mapping. Perhaps the most necessary and important bandl, without which the development would be much more difficult.
FosUserBundleprovides a complete set of functionality for working with users: registration, authorization, etc. in the same spirit.
SonataUserBundleintegrates FOSUserBundle into SonataAdminProject
SonataAdminBundlegives the functionality to create the administrative part of the site: the creation of basic bundles, editing, deleting data, as well as various additional features, such as exporting data to various formats. By itself, this bundle has quite flexible options for customization and customization to fit your needs.
KnpMenuBundlebundle and library for dynamic menu generation. As ways uses routes.
KnpPaginatorBundlecreates dynamic pagination for the site.
FOSRestBundleThis bundle provides a set of tools for the rapid development of the RESTful API and applications.
SonataPageBundleprovides control to Site entities (Page set), Page (the bundle provides several types of pages and it is easier to get CMS functionality for these pages), Block (content is managed by services, and Block contains the service id, position on the page and some service settings), Cache ( depending on the content, you can attach a caching service to each block)
SonataNewsBundleA blog based platform Doctrine2 and Symfony2, allows you to manage the type of routes, text formatting, comments
ecommerce
includes various bundles necessary for trade; Product, Price, Customer, Basket, Delivery, Order, Payment, Invoice
SonataCacheBundle
Unlike other caching solutions, an array with some data is used as the name of the entity, instead of the string or the object itself. And already behind the backend is the task of calculating the identifier for this array. An interesting solution, but I like it better <a href=.github.com/FriendsOfSymfony/FOSHttpCacheBundle> FOSHttpCacheBundle




Encountering scan problems


There are no special difficulties, the application is maintained in a healthy state.


Knp RAD project


Description


Bundle significantly reduces the amount of code required to perform standard tasks (sending mail, flash messages, auto-registration services, creating forms). There is also an assistant for creating missing view templates; if the template was not found, you can create it directly in the browser directly on the form on the error page.

Of the disadvantages of a small community and the need for additional study.
In addition, SensioGeneratorBundle copes well with generating Bundle, Controller, CRUD, Entity, FormType. And its use is more understandable than hiding this code with KnpRadBundle.

[ Project Wiki ]

Installation


Composer$ composer create-project -s dev --prefer-dist --dev knplabs / rad-edition knprad_project
$ cd knprad_project

Basic bundles


Table with titles and short description
KnpradbundleThe bundle itself, which allows to reduce a lot of code (judging by the examples )
DoctrineFixturesBundlework with fixtures for the database. It greatly simplifies life at the development stage, when it is necessary to constantly generate some kind of test information.
MopaBootstrapBundletwig-templates and extensions for more comfortable using twitter bootstrap
Behat + MinkTest bundles implement the BDD (behavior-driven development) approach.

It is better to use BehatBundle instead: Symfony2Extension



Encountering scan problems


No problem.

Symfony2 blog


Description


A simple blog is created based on symfony SE . The link to the source is a step-by-step description of the creation process, but it is better to focus on the Sonata sandbox , within which a small blog is also implemented. Better in the sense that in the Sonata project there are constant updates of the demo.

[ Source ]

Installation


Git$ git clone github.com/dsyph3r/symblog.git
$ cd symblog

Basic bundles


Only symfony SE is used .

Encountering scan problems


This lesson has been around for several years now and using the old version of Symfony2 (2.0.3). Not even used composer.

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


All Articles