|
| 1 | +# Base Laravel React |
| 2 | + |
| 3 | +A modern web application built with Laravel 12, Inertia.js, React, and ShadcnUI, containerized with Docker. |
| 4 | + |
| 5 | +## Technologies |
| 6 | + |
| 7 | +This project leverages several powerful technologies: |
| 8 | + |
| 9 | +- [Laravel 12](https://laravel.com/) - PHP web application framework |
| 10 | +- [Inertia.js](https://inertiajs.com/) - Modern monolithic architecture connecting Laravel to React |
| 11 | +- [React](https://reactjs.org/) - JavaScript library for building user interfaces |
| 12 | +- [ShadcnUI](https://ui.shadcn.com/) - A collection of reusable UI components |
| 13 | +- [FrankenPHP](https://frankenphp.dev/) - Modern PHP application server |
| 14 | +- [Docker](https://www.docker.com/) - Containerization platform |
| 15 | +- [SQLite](https://www.sqlite.org/) - Embedded database |
| 16 | + |
| 17 | +## Development Setup |
| 18 | + |
| 19 | +### Prerequisites |
| 20 | + |
| 21 | +- Docker and Docker Compose |
| 22 | +- Git |
| 23 | + |
| 24 | +### Getting Started |
| 25 | + |
| 26 | +1. Clone the repository: |
| 27 | + ```bash |
| 28 | + git clone <repository-url> |
| 29 | + cd <repository-name> |
| 30 | + ``` |
| 31 | + |
| 32 | +2. Start the development environment: |
| 33 | + ```bash |
| 34 | + docker-compose up -d |
| 35 | + ``` |
| 36 | + |
| 37 | +3. Install PHP dependencies: |
| 38 | + ```bash |
| 39 | + docker-compose run --rm composer install |
| 40 | + ``` |
| 41 | + |
| 42 | +4. Install JavaScript dependencies: |
| 43 | + ```bash |
| 44 | + docker-compose run --rm npm install |
| 45 | + ``` |
| 46 | + |
| 47 | +5. Build frontend assets: |
| 48 | + ```bash |
| 49 | + docker-compose run --rm npm run dev |
| 50 | + ``` |
| 51 | + |
| 52 | +6. Generate application key: |
| 53 | + ```bash |
| 54 | + docker-compose exec app php artisan key:generate |
| 55 | + ``` |
| 56 | + |
| 57 | +7. Run database migrations: |
| 58 | + ```bash |
| 59 | + docker-compose exec app php artisan migrate |
| 60 | + ``` |
| 61 | + |
| 62 | +The application should now be accessible at `https://localhost` (you may need to accept the self-signed certificate). |
| 63 | + |
| 64 | +For live frontend development: |
| 65 | +```bash |
| 66 | +docker-compose run --rm npm run dev |
| 67 | +``` |
| 68 | + |
| 69 | +## Production Deployment |
| 70 | + |
| 71 | +To deploy to production: |
| 72 | + |
| 73 | +1. Ensure your environment variables are properly set for production. |
| 74 | + |
| 75 | +2. Build and start the production containers: |
| 76 | + ```bash |
| 77 | + docker-compose -f docker-compose.prod.yml up -d |
| 78 | + ``` |
| 79 | + |
| 80 | +3. Run database migrations: |
| 81 | + ```bash |
| 82 | + docker-compose -f docker-compose.prod.yml exec app php artisan migrate --force |
| 83 | + ``` |
| 84 | + |
| 85 | +The production environment uses optimized Docker images with precompiled assets. |
| 86 | + |
| 87 | +## Code Quality Tools |
| 88 | + |
| 89 | +### Frontend |
| 90 | + |
| 91 | +- **ESLint** - JavaScript linting |
| 92 | +- **Prettier** - Code formatter |
| 93 | +- **TypeScript** - Static type checking |
| 94 | + |
| 95 | +Run the frontend linting: |
| 96 | +```bash |
| 97 | +docker-compose run --rm npm run lint |
| 98 | +``` |
| 99 | + |
| 100 | +Format frontend code: |
| 101 | +```bash |
| 102 | +docker-compose run --rm npm run format |
| 103 | +``` |
| 104 | + |
| 105 | +### Backend |
| 106 | + |
| 107 | +- **Laravel Pint** - PHP code style fixer |
| 108 | +- **PHPStan/Larastan** - Static analysis tool |
| 109 | +- **Rector** - PHP code quality tool and automatic refactoring |
| 110 | + |
| 111 | +Run the backend code style fixes: |
| 112 | +```bash |
| 113 | +docker-compose run --rm composer pint |
| 114 | +``` |
| 115 | + |
| 116 | +Run static analysis: |
| 117 | +```bash |
| 118 | +docker-compose run --rm composer analyse |
| 119 | +``` |
| 120 | + |
| 121 | +## Directory Structure |
| 122 | + |
| 123 | +The project follows the standard Laravel directory structure with additional organization for React components: |
| 124 | + |
| 125 | +- `app/` - Laravel PHP code |
| 126 | +- `resources/js/` - React components and frontend code |
| 127 | +- `resources/css/` - CSS and styling |
| 128 | +- `public/` - Static assets and compiled frontend code |
| 129 | +- `routes/` - Application routes |
| 130 | +- `database/` - Database migrations and seeders |
| 131 | + |
| 132 | +## License |
| 133 | + |
| 134 | +[MIT License](LICENSE) |
0 commit comments