php - Symfony MVC best practice for controllers -
in symfony/doctrine/php-project, client complaining we've broken software development best practices. complaint improper layering of source code, , lack of unit tests.
- this sub $50k-project.
- i believe client has expert java world, perhaps spring framework, looking @ source code.
we've been using proper mvc, see it.
- view-logic handled entirely twig.
- database handled entirely doctrine.
- we're using symfony security access control
($this->get('security.context')->isgranted('role_admin')
,$this->get('security.context')->gettoken()->getuser()
.
beware symfony has changed model bit, since started project - remains backward compatible.
in controller customer saying it's wrong controller handle:
- access control (via symfony security)
- database queries (via doctrine)
- "parsing , other logic" sending responses (
return $this->render('some_template.html.twig');
)
the question
the client saying best practices controller pass on requests layer further down in system.
further he's saying user-admin based on "custom model" users , roles stored in database - makes plugging in different access control system difficult. because role names seems hard coded such via commands such ($this->get('security.context')->isgranted('role_admin')
.
so; there definitive best practice on field? belongs in controller, , doctrine, twig, symfony security "sufficiently" separate layer "below controller".
should there yet layer between controller , doctrine example?
source: http://fabien.potencier.org/what-is-symfony2.html
first, symfony2?
first, symfony2 reusable set of standalone, decoupled, , cohesive php components solve common web development problems.
then, based on these components, symfony2 full-stack web framework.
depending on project , depending on needs, can either pick , choose of symfony2 components , start project them, or can use full-stack framework , benefit tight integration provides out of box. , choosing between 2 different approaches you.
is symfony2 mvc framework?
symfony2 providing tools controller part, view part, not model part. it's create model hand or use other tool, orm. of course, tight integration exists known orms doctrine2 , propel; optional dependencies. symfony2 core features not , never rely on orm.
symfony2 http framework; request/response framework. that's big deal. fundamental principles of symfony2 centered around http specification.
symfony best practices: http://symfony.com/doc/current/best_practices/index.html
you should rly read this controller best practices: http://symfony.com/doc/current/best_practices/controllers.html
you can read answer https://stackoverflow.com/a/21701890/2160958
Comments
Post a Comment