Giter Site home page Giter Site logo

bundleless's Introduction

Symfony without a Bundle? Welcome to Bundleless!

This is a very simple proof of concept. This package basically provides a bundle class which can be used to create "virtual" bundles. Virtual bundles only exists for the Symfony kernel, but for you it's just a package which uses bundle conventions (like automatic mapping for Entity/).

This can be used to remove the "bundle" from AppBundle. Let me tell you how to get this working for your application.

Install

This is pretty simple (if you're using Composer):

$ composer require wouterj/bundleless:1.*@dev

Edit

Use the new WouterJ\Bundleless\AppFocusedKernel as parent of your AppBundle:

// app/AppKernel.php

use WouterJ\Bundleless\AppFocusedKernel;

// ...
class AppKernel extends AppFocusedKernel
{
}

Then, remove that ugly AppBundle register line from your AppKernel. Bundeless will take care of it now.

// app/AppKernel.php

// ...
public function registerBundles()
{
    $bundles = array(
        // ...
        // comment or remove
        // new AppBundle\AppBundle();
}

Use

You're already ready! You should move your application code outside of the AppBundle by removing the namespace and putting it in src/ directly. For instance:

// src/Controller/StaticController.php
namespace App\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class StaticController extends Controller
{
    /**
     * @Route("/")
     */
    public function homepageAction()
    {
        return $this->render('static/homepage.html.twig');
    }
}
# app/config/routing.yml
app:
    resource: "@App/Controller"
    type: annotation

That's it. Apart from the template file, you now have a working homepage!

Customize

The AppBundle is created using the Kernel#getAppBundle() method. Override this method in your AppKernel to customize it.

License

This project is released under the MIT license, it's just 2 files anyway.

bundleless's People

Contributors

wouterj avatar zebba avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zebba

bundleless's Issues

router:debug returns an exception

Running php app/console router:debug does not work as expected:

 [Symfony\Component\Debug\Exception\ContextErrorException]                                                                                                                             
  Warning: strpos(): Empty needle in /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php line 94

I narrowed down the issue to ControllerNameParser::build(). The $controller parameter is resolved to:

web_profiler.controller.profiler:toolbarAction
...
web_profiler.controller.exception:showAction
...
Sensio\Bundle\DistributionBundle\Controller\ConfiguratorController::checkAction
...
\Controller\Report\Api\TemplateController::indexAction

The last controller is located in src/Controller/Report/Api/TemplateController.php

I was not able to narrow it down any further however, since I can't seem to find the line where build() is actually called from.

Mapping is not recognized due to Doctrine internals

After discusing the issue with @wouterj due to Doctrine internals you need to add your mapping by hand.

For now, as a quick fix, add the mapping to your config.yml:

doctrine:
    # ...
    orm:
        auto_mapping: true
        mappings:
            Entity:
                type: annotation
                prefix: Entity
                dir: %kernel.root_dir%/../src/Entity

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.