| .ddev | ||
| .idea | ||
| assets | ||
| bin | ||
| config | ||
| migrations | ||
| public | ||
| src | ||
| templates | ||
| tests | ||
| .editorconfig | ||
| .env | ||
| .env.dev | ||
| .env.test | ||
| .gitignore | ||
| compose.override.yaml | ||
| compose.yaml | ||
| composer.json | ||
| composer.lock | ||
| ecs.php | ||
| example_data.sql | ||
| package-lock.json | ||
| package.json | ||
| phpunit.xml.dist | ||
| README.md | ||
| symfony.lock | ||
| time.log | ||
| vite.config.js | ||
Vite Integration with Bootstrap and Select2
This project uses Vite as a frontend build tool to compile and serve Bootstrap and Select2 assets locally.
Setup
Install Dependencies
# Install PHP dependencies
composer install
# Install JavaScript dependencies
npm install
Development
To start the Vite development server:
npm run dev
This will start a development server at http://localhost:5173 that will automatically reload when you make changes to your assets.
Production Build
To build the assets for production:
npm run build
This will compile and minify your assets and place them in the public/build directory.
Usage
Bootstrap
Bootstrap is available globally through the bootstrap variable:
// Show a modal
const myModal = new bootstrap.Modal(document.getElementById('myModal'));
myModal.show();
Select2
Select2 is initialized automatically for elements with the select2 class:
<select class="select2">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</select>
You can also initialize Select2 manually:
$('#mySelect').select2();
Asset Structure
assets/app.js: Main entry point for JavaScriptassets/styles/app.css: Main entry point for CSS
Configuration
- Vite configuration:
vite.config.js - Symfony Vite Bundle configuration:
config/packages/pentatrion_vite.yaml
Testing
This project includes functional tests that verify all accessible pages can be accessed by the appropriate user roles.
Running Tests
To run the tests, you can use one of the following methods:
Using Composer
# Run all tests
composer test
# Run tests with code coverage report (saved to var/coverage/)
composer test-coverage
Using the Shell Script
bin/run-tests.sh
This script will:
- Install the test dependencies
- Create a test database if it doesn't exist
- Run migrations on the test database
- Run the tests using PHPUnit
Running Specific Tests
# Using PHPUnit directly
php bin/phpunit tests/Controller/HelloWorldControllerTest.php
# Or with a specific test method
php bin/phpunit --filter testIndexAsUser tests/Controller/HelloWorldControllerTest.php
Test Coverage
The tests cover all controllers and routes in the application, verifying access for:
- Anonymous users
- Users with ROLE_USER
- Users with ROLE_ADMIN
For more details about the test coverage, see the tests/README.md file.
Code Quality
Easy Coding Standard (ECS)
This project uses Easy Coding Standard to ensure consistent code style following Symfony standards.
Check Code Style
To check your code for style violations:
composer check-cs
Fix Code Style
To automatically fix code style violations:
composer fix-cs
The ECS configuration is defined in ecs.php in the project root.