Package Management
Relevant source files
The following files were used as context for generating this wiki page:
Package management in this project is handled through a dual-system approach: Composer for PHP-side dependencies and backend logic, and NPM/Vite for frontend assets and JavaScript modules. This ensures a clean separation between the server-side framework requirements and the client-side build pipeline.
The system is designed to automate the discovery and registration of packages. For PHP, the framework utilizes an auto-discovery mechanism that detects installed Laravel-specific packages to register their service providers and facades automatically. On the frontend, Vite acts as the primary build tool, managing dependencies like Tailwind CSS and Axios while providing a hot-module replacement (HMR) environment for development.
Backend Dependency Management (Composer)
The project uses Composer as its primary dependency manager for PHP. It defines the core framework requirements, development tools, and autoloading rules for the application's PSR-4 structure.
Core Dependencies and Development Tools
The application relies on laravel/framework as its primary dependency. Development-specific tools are separated to ensure they are not included in production environments.
| Package | Category | Purpose |
|---|---|---|
laravel/framework | Require | Core web application framework. |
laravel/tinker | Require | REPL for interacting with the application. |
phpunit/phpunit | Require-Dev | Testing framework for unit and feature tests. |
laravel/sail | Require-Dev | Docker development environment. |
laravel/pint | Require-Dev | PHP code style fixer. |
fakerphp/faker | Require-Dev | Library for generating fake data for testing. |
Sources: composer.json:1-25
Automation Scripts and Lifecycle Hooks
The composer.json file contains several scripts that automate environment setup and package maintenance.
The diagram shows the sequence of automation tasks triggered during package installation and updates.
- Package Discovery: The
package:discovercommand is automatically run after the autoloader is dumped to identify and register package services. - Asset Publishing: The
post-update-cmdensures that assets from updated packages (tagged aslaravel-assets) are forcefully republished to the public directory. - Custom Setup: A shorthand
setupscript provides a one-command solution for fresh installations, covering both PHP and Node.js requirements.
Sources: composer.json:43-80
Frontend Asset Management (NPM & Vite)
Frontend dependencies are managed via NPM, while the compilation and bundling logic is handled by Vite. The project is configured as a native ECMAScript Module (ESM) environment.
Frontend Dependencies
The project utilizes a modern frontend stack focusing on utility-first CSS and asynchronous HTTP requests.
| Dependency | Version | Role |
|---|---|---|
vite | ^7.0.7 | Next-generation frontend build tool. |
laravel-vite-plugin | ^2.0.0 | Bridges Vite with the Laravel backend. |
tailwindcss | ^4.0.0 | Utility-first CSS framework. |
axios | ^1.11.0 | Promise-based HTTP client for the browser. |
Sources: package.json:1-15
Build Pipeline Configuration
The vite.config.js file configures how assets are processed. It defines the entry points for the application's CSS and JavaScript and specifies which files should be ignored by the hot-reload watcher (specifically compiled Blade views in the storage directory).
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
tailwindcss(),
],
server: {
watch: {
ignored: ['**/storage/framework/views/**'],
},
},
});
Sources: vite.config.js:5-18
Integration and Autoloading
The integration between the package managers and the runtime environment occurs during the early stages of the request lifecycle.
Runtime Bootstrapping
When a request enters the application through public/index.php, the system immediately loads the Composer-generated autoloader. This file maps all installed PHP packages to their respective classes, allowing for seamless dependency injection and class instantiation.
The diagram illustrates the critical role of the autoloader in the application startup sequence.
Sources: public/index.php:1-20
Autoloading Standards
The project follows PSR-4 autoloading standards. The application's core logic is mapped to the App\ namespace, while database-related classes are mapped to Database\.
- App Namespace: Mapped to
app/. - Database Factories: Mapped to
database/factories/. - Database Seeders: Mapped to
database/seeders/. - Test Suite: Development-only testing classes are mapped to the
Tests\namespace within thetests/directory.
Sources: composer.json:26-38