|
1 | | -# Laravel 12 Swoole - Vue3 template |
2 | | - |
3 | | -<p align="center"> |
4 | | - <a href="https://laravel.com" target="_blank"> |
5 | | - <img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"> |
6 | | - </a> |
7 | | -</p> |
8 | | - |
9 | | -<p align="center"> |
10 | | - <a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a> |
11 | | - <a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a> |
12 | | - <a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a> |
13 | | - <a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a> |
14 | | -</p> |
15 | | - |
16 | | -## Project Overview |
17 | | - |
18 | | -Laravel 12 as API backend using PHP 8.4.10 with a Swoole server, with role-based access & auth + a Vue3, Tailwind, DaisyUI frontend. |
19 | | -Complete with a docker-compose.yml containing MariaDB & Redis & Nginx to deploy on a server. |
20 | | - |
21 | | -### Optimize images |
22 | | - |
23 | | -```php |
24 | | -ImageOptimizer::optimize(storage_path('app/public/' . $pathToImage)); |
25 | | -``` |
26 | | - |
27 | | -### Development Setup |
28 | | - |
29 | | -1. Clone the repository |
30 | | -2. Edit `.env.example` and `docker-compose.yml` to match your environment |
31 | | -3. Run `docker compose up -d --build` |
32 | | -4. Generate application key: `php artisan key:generate` |
33 | | -5. Run storage link: `php artisan storage:link` |
34 | | -6. Run migrations: `php artisan migrate` |
35 | | -7. Run seeders: `php artisan db:seed` |
36 | | -8. Start development server: `npm run dev` |
37 | | -9. Access at `127.0.0.1:7654` |
| 1 | +# Laravel 12 Vue3 Boilerplate — Octane Swoole Redis Nginx 🚀 |
| 2 | + |
| 3 | +[](https://github.com/Jerry1765/laravel-vue-boilerplate/releases) |
| 4 | + |
| 5 | +[](https://laravel.com) [](https://vuejs.org) [](https://openswoole.com) [](https://redis.io) [](https://nginx.org) [](https://mariadb.org) |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +A ready-to-run starter kit built for high throughput and modern front-end. This repo pairs Laravel 12 with Octane on OpenSwoole, serves a Vue 3 SPA, uses Redis for cache and queue, and targets Nginx + MariaDB in production. |
| 10 | + |
| 11 | +Features |
| 12 | +- Laravel 12 base with modern folder layout |
| 13 | +- Octane setup using OpenSwoole for low-latency PHP workers |
| 14 | +- Vue 3 front-end scaffold with Vite |
| 15 | +- Redis for cache, sessions, and queues |
| 16 | +- Nginx sample config for reverse proxy and static assets |
| 17 | +- MariaDB migrations and seeders |
| 18 | +- Docker Compose for local dev and integration tests |
| 19 | +- Auth scaffold and API-first routing |
| 20 | +- Useful artisan and npm scripts for daily work |
| 21 | + |
| 22 | +Why use this boilerplate |
| 23 | +- Save setup time. The repo wires common services. |
| 24 | +- Run Octane with Swoole to keep PHP processes warm. |
| 25 | +- Use Vue 3 and Vite for fast front-end build and HMR. |
| 26 | +- Use Redis for session and queue back ends. |
| 27 | +- Ship with Nginx configuration for production. |
| 28 | + |
| 29 | +Table of contents |
| 30 | +- Quick start |
| 31 | +- Requirements |
| 32 | +- Local setup (Docker) |
| 33 | +- Manual setup (native) |
| 34 | +- Environment variables |
| 35 | +- Octane & OpenSwoole |
| 36 | +- Nginx sample config |
| 37 | +- Redis and queues |
| 38 | +- Database and migrations |
| 39 | +- Front-end (Vue 3) |
| 40 | +- Common commands |
| 41 | +- Testing |
| 42 | +- Deployment tips |
| 43 | +- Releases |
| 44 | +- Contributing |
| 45 | +- Credits |
| 46 | +- License |
| 47 | + |
| 48 | +Quick start |
| 49 | + |
| 50 | +Requirements |
| 51 | +- PHP 8.3+ with required extensions (swoole ext optional for Octane) |
| 52 | +- Composer 2+ |
| 53 | +- Node 18+ |
| 54 | +- Yarn or npm |
| 55 | +- Docker & Docker Compose (recommended) |
| 56 | +- Redis server |
| 57 | +- MariaDB or MySQL |
| 58 | + |
| 59 | +Local setup (recommended with Docker) |
| 60 | +1. Clone the repo |
| 61 | + git clone https://github.com/Jerry1765/laravel-vue-boilerplate.git |
| 62 | + cd laravel-vue-boilerplate |
| 63 | + |
| 64 | +2. Copy env |
| 65 | + cp .env.example .env |
| 66 | + |
| 67 | +3. Build and run |
| 68 | + docker compose up -d --build |
| 69 | + |
| 70 | +4. Install PHP deps (inside app container) |
| 71 | + docker compose exec app composer install --no-interaction |
| 72 | + |
| 73 | +5. Install JS deps |
| 74 | + docker compose exec node npm install |
| 75 | + |
| 76 | +6. Generate key and migrate |
| 77 | + docker compose exec app php artisan key:generate |
| 78 | + docker compose exec app php artisan migrate --seed |
| 79 | + |
| 80 | +7. Start Octane (inside app container) |
| 81 | + docker compose exec app php artisan octane:start --server=swoole --host=0.0.0.0 --port=8000 |
| 82 | + |
| 83 | +8. Open http://localhost:8000 or proxy via Nginx container |
| 84 | + |
| 85 | +Manual setup (native) |
| 86 | +1. Clone repo |
| 87 | + git clone https://github.com/Jerry1765/laravel-vue-boilerplate.git |
| 88 | + cd laravel-vue-boilerplate |
| 89 | + |
| 90 | +2. Install composer packages |
| 91 | + composer install |
| 92 | + |
| 93 | +3. Install JS packages |
| 94 | + npm ci |
| 95 | + npm run build |
| 96 | + |
| 97 | +4. Copy .env and set app key |
| 98 | + cp .env.example .env |
| 99 | + php artisan key:generate |
| 100 | + |
| 101 | +5. Configure DB and Redis in .env |
| 102 | + |
| 103 | +6. Run migrations and seeders |
| 104 | + php artisan migrate --seed |
| 105 | + |
| 106 | +7. Start Octane with OpenSwoole |
| 107 | + php artisan octane:start --server=swoole --host=127.0.0.1 --port=8000 |
| 108 | + |
| 109 | +Environment variables (important keys) |
| 110 | +- APP_NAME, APP_ENV, APP_URL |
| 111 | +- DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD |
| 112 | +- CACHE_DRIVER=redis |
| 113 | +- QUEUE_CONNECTION=redis |
| 114 | +- SESSION_DRIVER=redis |
| 115 | +- REDIS_HOST, REDIS_PORT, REDIS_PASSWORD |
| 116 | +- OCTANE_** (use to tune worker count in octane.php) |
| 117 | + |
| 118 | +Octane & OpenSwoole |
| 119 | +- This project uses Laravel Octane on OpenSwoole. |
| 120 | +- Octane keeps PHP worker processes alive. That reduces boot time. |
| 121 | +- Use octane:start for local runs. Use systemd or supervisord for production. |
| 122 | +- Tune worker count based on CPU and memory: |
| 123 | + octane: |
| 124 | + workers: CPU_CORES * 2 |
| 125 | +- Adjust swoole settings in config/octane.php and config/swoole.php when present. |
| 126 | +- Clear runtime caches between deployments: |
| 127 | + php artisan octane:reload |
| 128 | + or restart the Octane process. |
| 129 | + |
| 130 | +Nginx sample config |
| 131 | +Use this config as a starting point for production. Place it in sites-available and enable it. |
| 132 | + |
| 133 | +server { |
| 134 | + listen 80; |
| 135 | + server_name example.com; |
| 136 | + root /var/www/html/public; |
| 137 | + |
| 138 | + index index.php; |
| 139 | + |
| 140 | + location / { |
| 141 | + try_files $uri $uri/ /index.php?$query_string; |
| 142 | + } |
| 143 | + |
| 144 | + location ~ \.php$ { |
| 145 | + include fastcgi_params; |
| 146 | + fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; |
| 147 | + fastcgi_index index.php; |
| 148 | + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; |
| 149 | + } |
| 150 | + |
| 151 | + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { |
| 152 | + try_files $uri /index.php?$query_string; |
| 153 | + expires 30d; |
| 154 | + add_header Cache-Control "public, no-transform"; |
| 155 | + } |
| 156 | + |
| 157 | + client_max_body_size 50M; |
| 158 | +} |
| 159 | + |
| 160 | +If you run Octane behind Nginx, proxy traffic to the Octane host/port instead of FPM. |
| 161 | + |
| 162 | +Redis and queues |
| 163 | +- Use Redis for cache, session, and queues. |
| 164 | +- Set .env: |
| 165 | + CACHE_DRIVER=redis |
| 166 | + SESSION_DRIVER=redis |
| 167 | + QUEUE_CONNECTION=redis |
| 168 | +- Start a worker |
| 169 | + php artisan queue:work redis --tries=3 |
| 170 | +- For Octane, use queue:work in a separate process or use Horizon if you need a dashboard. |
| 171 | + |
| 172 | +Database and migrations |
| 173 | +- Migrations live in database/migrations. |
| 174 | +- Seeders in database/seeders. |
| 175 | +- Run: |
| 176 | + php artisan migrate |
| 177 | + php artisan db:seed |
| 178 | +- Use factories to generate test data: |
| 179 | + php artisan tinker |
| 180 | + User::factory()->count(50)->create(); |
| 181 | + |
| 182 | +Front-end (Vue 3 + Vite) |
| 183 | +- The front-end uses Vue 3 and Vite. |
| 184 | +- Structure: |
| 185 | + resources/js — Vue app |
| 186 | + resources/js/components — components |
| 187 | + resources/js/pages — SPA pages |
| 188 | +- Commands: |
| 189 | + npm run dev # local dev with HMR |
| 190 | + npm run build # build for production |
| 191 | + npm run lint # lint code |
| 192 | +- Use API routes for server data under routes/api.php |
| 193 | + |
| 194 | +Common commands |
| 195 | +- Composer |
| 196 | + composer install |
| 197 | + composer update |
| 198 | +- Artisan |
| 199 | + php artisan migrate |
| 200 | + php artisan db:seed |
| 201 | + php artisan octane:start --server=swoole |
| 202 | + php artisan octane:reload |
| 203 | + php artisan queue:work |
| 204 | +- NPM/Yarn |
| 205 | + npm ci |
| 206 | + npm run dev |
| 207 | + npm run build |
| 208 | + |
| 209 | +Testing |
| 210 | +- Tests live under tests/Feature and tests/Unit. |
| 211 | +- Run PHPUnit: |
| 212 | + ./vendor/bin/phpunit |
| 213 | +- Use parallel testing for speed: |
| 214 | + php artisan test --parallel |
| 215 | + |
| 216 | +Deployment tips |
| 217 | +- Build assets during CI and push the compiled assets to the server. |
| 218 | +- Use a process manager to keep Octane up. Examples: |
| 219 | + systemd unit that runs php artisan octane:start ... |
| 220 | +- Use Redis persistence strategy that matches your SLA. |
| 221 | +- Use zero-downtime release flow: |
| 222 | + - Push new code to a build directory. |
| 223 | + - Run composer install with --no-dev and optimized autoloader. |
| 224 | + - Run migrations. |
| 225 | + - Reload Octane: php artisan octane:reload |
| 226 | +- Back up your DB and Redis before major changes. |
| 227 | + |
| 228 | +Releases |
| 229 | + |
| 230 | +Download the release asset file from the Releases page and run the included installer script. Visit the releases page here: https://github.com/Jerry1765/laravel-vue-boilerplate/releases |
| 231 | + |
| 232 | +If the releases page contains a packaged archive, download the archive (for example, laravel-vue-boilerplate-vX.Y.Z.tar.gz) and execute the provided installer or setup script inside the archive. Example local steps after download: |
| 233 | +- tar -xzf laravel-vue-boilerplate-vX.Y.Z.tar.gz |
| 234 | +- cd laravel-vue-boilerplate-vX.Y.Z |
| 235 | +- chmod +x install.sh |
| 236 | +- ./install.sh |
| 237 | + |
| 238 | +If the releases link is not reachable, check the Releases section on this repository on GitHub. |
| 239 | + |
| 240 | +Contributing |
| 241 | +- Fork the repo. |
| 242 | +- Create a feature branch. |
| 243 | +- Write tests for new features. |
| 244 | +- Keep PRs small and focused. |
| 245 | +- Use conventional commit messages. |
| 246 | +- Run linters and tests before opening a PR. |
| 247 | + |
| 248 | +Labels and topics |
| 249 | +This repo targets these topics to help discoverability: |
| 250 | +boilerplate, laravel, laravel12, mariadb, nginx, openswoole, redis, redis-server, skeleton, starter, starter-kit, vue3 |
| 251 | + |
| 252 | +Credits |
| 253 | +- Laravel |
| 254 | +- Vue.js |
| 255 | +- OpenSwoole |
| 256 | +- Redis |
| 257 | +- Nginx |
| 258 | +- MariaDB |
| 259 | +- Community contributors |
| 260 | + |
| 261 | +Useful links and resources |
| 262 | +- Laravel docs — https://laravel.com/docs/12.x |
| 263 | +- Octane docs — https://laravel.com/docs/10.x/octane |
| 264 | +- OpenSwoole — https://openswoole.com |
| 265 | +- Vue 3 — https://vuejs.org |
| 266 | +- Vite — https://vitejs.dev |
| 267 | +- Redis — https://redis.io |
| 268 | +- Nginx — https://nginx.org |
| 269 | + |
| 270 | +License |
| 271 | +This project uses the MIT license. Check the LICENSE file for details |
0 commit comments