Developing your Application

Creating Bundles

It’s recommended that you create bundles to organize your application. The basic app comes with an example bundle to serve as model for your custom bundles.

There’s a console command to help creating the basic Bundle structure. Run:

$ php app/console bundle-create MyBundleName

A structure like this will be created:

├── Controller
│   └── DefaultController.php
└── Resources
    ├── config
    │   └── routing.yml
    └── views
        └── default
            └── index.html.twig

The name provided, in this case MyBundleName, will be the namespace of your bundle.

Activating a Bundle

You’ll need to add the new bundle path to the file app/config/config.yml, under the item “active_bundles”, as shown below:

    - "%root_dir%/src/ExampleBundle"
    - "%root_dir%/src/MyCustomBundle1"
    - "%root_dir%/src/MyCustomBundle2"

You’ll also need to include the routing file for the bundle inside the main app/config/routing.yml. Edit this file and add the relevant import statements:

    resource: "src/MyCustomBundle1/Resources/config/routing.yml"

    resource: "src/MyCustomBundle2/Resources/config/routing.yml"

Overwriting Templates

You can overwrite the default templates that come with the core Twilex bundle. To overwrite a template, you just need to create a template under the same structure as the default ones. The default templates are located at the main twilex/twilex bundle, at vendor/twilex/twilex/src/Twilex/Resources/views.

If you check the ExampleBundle views folder, you’ll notice that the template default/index.html overwrites the default index template from the twilex/twilex bundle.

Note: when overwriting templates, the highest priority is for the first bundle included in the list of `active_bundles`.


For now, all assets are located in the web directory, in the root of the application. For future versions, an integration with Assetic for assets management is planned.

Default Routes

Twilex comes with two main routes that you’ll need for connecting your users to Twitter:


This is the entrypoint for authorization on Twitter. After authorizing, the user should be redirected here in order to finish the authentication process. You need to use this route in the callback url of your Twitter App.


This is the route for logging out the user.


You can also create custom routes / controllers for the authorization process. Check the ConnectController (from the main twilex/twilex bundle) to have an idea of how we send a user for authorization.

Creating Console Commands

The ExampleBundle included in the installation has an example of a Console Command. You can create your own console commands, and to make them available in the included app/console you just need to place them inside a “Command” folder in your bundle, following the standard nomenclature “SomethingCommand.php” for the class name.

Check ExampleBundle/Command/ExampleCommand.php to see how you can create Commands, or have a look at the Symfony documentation about the Console component.