It's a simple blog site with CRUD operations. During the development phase, I used packages for forms, validation, DB access, tests, Twig templating, CLI tools, etc. I developed the app by using the following technologgies:
- PHP 8.3
- Symfony 7.4
- MySQL 8.0 -> PHPmyadmin
- Apache Server
- MAMP
shell brew install symfony-cli/tap/symfony-cli
shell composer require symfony/twig-bundle
shell composer require symfony/maker-bundle --dev
shell composer require symfony/orm-pack
shell composer require orm-fixtures --dev
shell composer require symfony/profiler-pack --dev
shell composer require symfony/form
shell composer require symfony/validator
- Create a symfony project:
symfony new project_name - Open the project:
cd project_name && code . - Start the server:
symfony serve - Open the page on browser: 'http://127.0.0.1:8000/'
- Define the namespace (App\Controller)
- Include necessary Symfony Components (Response, Route, etc.)
- Create an index function
- Return the output with response
- Create home directory
- Create index.html.twig
- Include base.html.twig
- Wrap in body block
- Change .env file for DB
- Create DB (posts):
php bin/console doctrine:database:create - Check db file in var directory and src/Entity
- Create entity (post):
php bin/console make:entity entity_name - Add tables to the entity: title (string), text, datetime
- Create the migration code:
php bin/console make:migration - Migrate the tables
php bin/console doctrine:migrations:migrate - Create test objects using orm-fixtures (src/DataFixtures/AppFixtures.php)
- Write test objects into DB:
php bin/console doctrine:fixtures:load - Check DB:
php bin/console dbal:run-sql "SELECT * FROM post" - Display the data in frontend (src/Controller/PostController.php)
- Check the data in frontend (dump, or dd methods)
- Connect TailwindCSS with CDN (templates/base.html.twig)
- Add a Navigation with home and posts links before {% body %} block
- Add a Footer after {% body %} block
- Define Show function to display a single post (PostController.php)
- Define Route to Show function (PostController.php)
- Define Show twig (templates/post/show.html.twig)
- Install symfony/form
- Create form logic:
php bin/console make:form - Define New function to create a new post (PostController.php)
- Define Route to New function (PostController.php)
- Define New twig (templates/post/new.html.twig)
- Set constraints to form fields with validator (src/Entitiy/Post.php)
- Create a success message for form submission (templates/base.html.twig)
- Define the message in PostController (src/Controller/PostController.php)
- Create a _form.html.twig component for common forms (new and edit, etc.)
- Remove the form from new.html.twig and refer the _form.html.twig, instead
- Create edit function (src/Controller/PostController.php)
- Create edit twig (templates/post/edit.html.twig)
- Add edit button and reference the link (templates/post/show.html.twig)
- Create delete function (src/Controller/PostController.php)
- Create delete twig (templates/post/delete.html.twig)
- Add delete button and reference the link (templates/post/show.html.twig)
- Use TailwindCSS to style frontend