diff --git a/README.md b/README.md index ad9d461..cbe4362 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ ## Requirements -* [Install Composer](https://www.nickyeoman.com/page/install-composer-on-ubuntu) (sudo nala install php-curl php-xml php-mysql) +* ubuntu php-cli (sudo nala install php-curl php-xml php-mysql) +* [Install Composer](https://www.nickyeoman.com/page/install-composer-on-ubuntu) * [Symfony cli](https://symfony.com/download) -* php-cli + ## Create your Project diff --git a/bin/nysymfony b/bin/nysymfony index 8cbcdf3..dec4c27 100755 --- a/bin/nysymfony +++ b/bin/nysymfony @@ -138,7 +138,7 @@ echo "DBUSER=theuser${GEN}" >> .env GEN=`echo $RANDOM | md5sum | head -c 12` echo "DBPASSWORD=${GEN}" >> .env echo '' >> .env -echo '# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8&charset=utf8mb4"' >> .env +echo '# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=mariadb-10.4.11&charset=utf8mb4"' >> .env # TODO: move these here after you have symfony production ready diff --git a/docs/Bundles.md b/docs/Bundles.md index 42c0acd..4f306a8 100644 --- a/docs/Bundles.md +++ b/docs/Bundles.md @@ -2,23 +2,123 @@ ## How to Create a bundle -[Official Symfony Docs - Create a bundle](https://symfony.com/doc/current/bundles.html#creating-a-bundle) +First we are going to get the bundle functioning in an existing project, then move it to composer/packigst. -mkdir -p lib/bundleName/src -touch lib/bundleName/src/bundleName.php +### Create files and directories -You have to add the namespace\bundle name to config/bundles.php -```vendorName\bundleName\bundleName::class => ['all' => true],``` - -And you have to auto load the class by adding the next line in composer.json: +Example: +```bash +newdirs='lib/ContactForm/src' +mkdir -p ${newdirs}/Controller ${newdirs}/Controller ${newdirs}/Entity ${newdirs}/Repoository ${newdirs}/DependencyInjection +touch ${newdirs}/Controller/ContactFormController.php +touch ${newdirs}/ContactForm.php +touch ${newdirs}/Controller/ContactForm.php ``` + +The ContactFormController.php example: +```php +render('@SymfonyCMS/dashboard.html.twig', [ + 'controller_name' => 'ContactFormController', + ]); + } +} +``` +You will have to make changes to namespace, classname, route, render. + +The ContactForm.php file example: +```php + ['all' => true],``` +composer would do this automatically if it was grabbing from packigst, but we are just using a dev environment for now. Example: +```php +NickYeoman\ContactForm\ContactForm::class => ['all' => true], +``` + +### Symfony Bundle Config + +Create a DependencyInjection file: +```php +load('services.yaml'); + } +} + +``` + + +Next create a service in config/services.yaml: +```yaml +services: + NickYeoman\ContactForm\Controller\: + resource: '../src/Controller/' + tags: ['controller.service_arguments'] +``` + +Finally, you can specify the route. Create a new route file config/routes.yaml +```yaml +ContactForm: + resource: + path: ../src/Controller/ + namespace: NickYeoman\ContactForm\Controller + type: attribute +``` + + +## Resources + +* [Official Symfony Docs - Create a bundle](https://symfony.com/doc/current/bundles.html#creating-a-bundle) +* [Symfony casts - Bootstrapping](https://symfonycasts.com/screencast/symfony-bundle/bundle-directory) \ No newline at end of file diff --git a/docs/Resources.md b/docs/Resources.md index 36f00cf..0aab434 100644 --- a/docs/Resources.md +++ b/docs/Resources.md @@ -2,4 +2,6 @@ * [Symfony 6 full course](https://www.youtube.com/watch?v=QPky3r2prEI) * [Symfony6 for beginners](https://www.youtube.com/watch?v=PMERdlfL6LE&list=PLFHz2csJcgk-t8ErN1BHUUxTNj45dkSqS) -* [Symfonycasts](https://symfonycasts.com/tracks/symfony) \ No newline at end of file +* [Symfonycasts](https://symfonycasts.com/tracks/symfony) +* https://github.com/msalsas/symfony-bundle-skeleton +* [bundle medium](https://macrini.medium.com/how-to-create-service-bundles-for-a-symfony-application-f266ecf01fca)