mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-12-12 21:33:13 +00:00
91 lines
1.5 KiB
Markdown
91 lines
1.5 KiB
Markdown
# Create a new bundle {#create-new-bundle}
|
|
|
|
:::: warning
|
|
::: title
|
|
Warning
|
|
:::
|
|
|
|
This part of the doc is not yet tested
|
|
::::
|
|
|
|
## Create a new directory with Bundle class
|
|
|
|
``` bash
|
|
mkdir -p src/Bundle/ChillSomeBundle/src/config
|
|
mkdir -p src/Bundle/ChillSomeBundle/src/Controller
|
|
```
|
|
|
|
Add a bundle file
|
|
|
|
``` php
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\SomeBundle;
|
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|
|
|
class ChillSomeBundle extends Bundle {}
|
|
```
|
|
|
|
And a route file:
|
|
|
|
``` yaml
|
|
chill_ticket_controller:
|
|
resource: '@ChillTicketBundle/Controller/'
|
|
type: annotation
|
|
```
|
|
|
|
## Register the new psr-4 namespace
|
|
|
|
In composer.json, add the new psr4 namespace
|
|
|
|
``` diff
|
|
{
|
|
"autoload": {
|
|
"psr-4": {
|
|
+ "Chill\\SomeBundle\\": "src/Bundle/ChillSomeBundle/src",
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Register the bundle
|
|
|
|
Register in the file `config/bundles.php`:
|
|
|
|
``` php
|
|
Vendor\Bundle\YourBundle\YourBundle::class => ['all' => true],
|
|
```
|
|
|
|
And import routes in `config/routes/chill_some_bundle.yaml`:
|
|
|
|
``` yaml
|
|
chill_ticket_bundle:
|
|
resource: '@ChillSomeBundle/config/routes.yaml'
|
|
```
|
|
|
|
## Add the doctrine_migration namespace
|
|
|
|
Add the namespace to `config/packages/doctrine_migrations_chill.yaml`
|
|
|
|
``` diff
|
|
doctrine_migrations:
|
|
migrations_paths:
|
|
+ 'Chill\Some\Ticket': '@ChillSomeBundle/migrations'
|
|
```
|
|
|
|
## Dump autoloading
|
|
|
|
``` bash
|
|
symfony composer dump-autoload
|
|
```
|