Giter Club home page Giter Club logo

hexagonal-symfony's Introduction

Hexagonal Symfony

Welcome to the Hexagonal Symfony. This is a sandbox for experimenting with Cockburn's hexagonal ideas with Symfony2.

Note: this is work in progress, your PR is welcome!

Installation

Download composer, add it to your path, go to the root of the project and run:

composer.phar install

This installs the project dependencies like Symfony2. Next create a database, a database schema and load the fixtures.

app/console doctrine:database:create
app/console doctrine:schema:create
app/console doctrine:fixtures:load

The only fixture that is loaded is a Project Manager with login "everzet" and password "qwerty".

For the ease of use, this application can be used with Vagrant with:

vagrant up

Features

The core of this application is a project management system. The features are "documented" in the tests. You can run the tests with behat:

bin/behat

There are also phpspec tests. Run them with:

bin/phpspec --format=pretty

See also

hexagonal-symfony's People

Contributors

cordoval avatar liuggio avatar marcelloduarte avatar michalpipa avatar tvlooy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexagonal-symfony's Issues

Login is broken

Somehow the session file is not stored on the server (/var/lib/php5). After entering the correct credentials (everzet / qwerty) the login form redirect back to the login form.

dev.log:

...
[2014-10-27 05:43:21] doctrine.DEBUG: SELECT t0.username AS username1, t0.password AS password2, t0.salt AS salt3, t0.id AS id4 FROM ProjectManager t0 WHERE t0.username = ? LIMIT 1 ["everzet"] []
[2014-10-27 05:43:21] security.INFO: User "everzet" has been authenticated successfully [] []
[2014-10-27 05:43:21] event.DEBUG: Listener "Symfony\Component\Security\Http\Firewall::onKernelRequest" stopped propagation of the event "kernel.request". [] []
[2014-10-27 05:43:21] event.DEBUG: Listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest" was not called for event "kernel.request". [] []
[2014-10-27 05:43:21] event.DEBUG: Listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger" was not called for event "kernel.request". [] []
[2014-10-27 05:43:21] event.DEBUG: Listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger" was not called for event "kernel.request". [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse". [] []
[2014-10-27 05:43:21] security.DEBUG: Write SecurityContext in the session [] []
...
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2014-10-27 05:43:21] request.INFO: Matched route "list_my_projects" (parameters: "_controller": "controllers.list_my_projects:listAction", "_route": "list_my_projects") [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2014-10-27 05:43:21] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2014-10-27 05:43:21] security.INFO: Populated SecurityContext with an anonymous Token [] []

Fixture loading should be done through a use case

Marcello, what are your thoughts on requiring loading fixtures to utilize a use case service?

For example, LoadProjectManagers creates ProjectManager entities. This could be encapsulated in a use case CreateProjectManager. Should that service be used to create and persist the new ProjectManager entity in a fixture class? Or is loading a ProjectManager fixture its own use case?

    public function load(ObjectManager $manager)
    {
        $users = ['everzet' => 'qwerty'];
        foreach ($users as $username => $password) {
            $pm = $this->container->get('use_case.create_project_manager')->createProjectManager($username, $password);
            $this->addReference('project_manager.' . $username, $pm);
        }
    }

Your fixture class then does little more than list the fixture users you wish to create then leverage the use cases service. The fixture class could of course still use setReference() to coordinate with other fixtures, but it stays within its single responsibility.

The lifecycle of creating a ProjectManager would then be consistent across the application, no matter if the ProjectManager were created in the Controller, an interactive Command, or in this case a Fixture. This includes how a User's password is encoded. You would not want your fixture-loaded ProjectManager users to have their passwords encoded differently than those created through a Controller.

OR do you consider DataFixtures a very focused use case themselves that load raw entities into the database? Perhaps your CreateProjectManager service dispatches an event whose listener emails the ProjectManager user a welcome email. You certainly would not want a fixture class triggering a real email to anyone?

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.