A ready-to-use CakePHP 5 starter kit with DDEV, Redis support, and environment validation.
- CakePHP 5.x skeleton
- DDEV local development environment
- Redis caching & sessions (optional, falls back to file-based)
- Environment prerequisite validation before boot
- Database connection setup wizard
- Vite integration with Hot Module Replacement (HMR)
- CakeSPA - Server-driven SPA architecture (Livewire-like reactivity)
- DbConfig - Database-driven application configuration
- PHP 8.1+
- Required PHP extensions: intl, mbstring, openssl, pdo, json
- Composer
- Node.js & npm (if using frontend assets)
- MySQL/MariaDB or PostgreSQL
- DDEV (optional, for local development)
-
Clone the repository:
git clone https://github.com/CakePHPMitra/StarterKit.git my-app cd my-app -
Start DDEV:
ddev start
-
Install dependencies:
ddev composer install
-
Launch the application:
ddev launch
-
Clone the repository:
git clone https://github.com/CakePHPMitra/StarterKit.git my-app cd my-app -
Install PHP dependencies:
composer install
-
Install Node dependencies (if applicable):
npm install
-
Configure environment:
cp config/.env.example config/.env
-
Set directory permissions:
chmod -R 775 logs tmp
-
Start the built-in server:
bin/cake server -p 8765
-
Visit
http://localhost:8765
- Copy
config/.env.exampletoconfig/.envand configure your environment - Redis is automatically enabled when
REDIS_HOSTis set (falls back to file-based caching if unavailable) - Database configuration can be done via the setup wizard or manually in
.env
The starter kit includes automatic environment validation:
- PHP extensions: intl, mbstring, openssl, pdo, json
- Vendor directory (
composer install) - Node modules (if using Vite)
- Writable directories:
logs/,tmp/
- Database: Connection validation with setup wizard
- Redis: Optional - validates connection if
REDIS_HOSTis configured - Vite Manifest: Validates
webroot/build/.vite/manifest.jsonwhen dev server is not running
If any check fails, a friendly setup page is displayed with clear instructions.
Note: Comment or remove REDIS_HOST from config/.env if not using Redis.
This starter kit uses CakePHP's fallback routes for convenience. All controller actions are automatically routed using the pattern /{controller}/{action}.
Custom routes are defined in config/routes.php. Add explicit routes for:
- SEO-friendly URLs
- Custom URL patterns
- API versioning
// Example custom routes
$builder->connect('/about', ['controller' => 'Pages', 'action' => 'display', 'about']);
$builder->connect('/contact', ['controller' => 'Contact', 'action' => 'index']);Note: Controller methods that should not be accessible via URL should be marked as protected or private.
This starter kit includes CakePhpViteHelper for modern frontend asset bundling with Hot Module Replacement.
bin/cake vite-helper installThis will install Node dependencies and configure Vite for your project. The installer automatically configures Vite to work with:
- DDEV - Uses
DDEV_HOSTNAMEenvironment variable - Local network - Detects Ethernet/Wi-Fi IP for LAN access
- Localhost - Falls back to
0.0.0.0for local development
Add the following to your .ddev/config.yaml to expose the Vite port:
web_extra_exposed_ports:
- name: vite
container_port: 5173
http_port: 5172
https_port: 5173Then restart DDEV:
ddev restartRun the Vite dev server for HMR:
# Local development
npm run dev
# With DDEV
ddev exec npm run devThe Vite dev server will be accessible at:
- Local:
http://localhost:5173orhttp://<your-ip>:5173 - DDEV:
https://your-project.ddev.site:5173
Build assets for production:
npm run buildAssets are loaded via the Vite helper in your layout:
<?= $this->Vite->asset(['resources/js/app.js', 'resources/css/app.css']) ?>Frontend assets are located in the resources/ directory:
resources/js/app.js- Main JavaScript entryresources/css/app.css- Main stylesheet
This starter kit includes CakeSPA for server-driven SPA architecture - build reactive applications without JavaScript frameworks.
- SPA Navigation - Load pages via AJAX with History API support
- Reactive Components - Livewire-like reactivity without writing JavaScript
- CSRF Compatible - Full security integration with CakePHP
- Subdirectory Support - Automatic base URL detection for alias deployments
The SPA helper and scripts are already loaded in the default layout. Use SPA navigation links:
<?= $this->Spa->navLink('Home', '/') ?>
<?= $this->Spa->navLink('About', '/about') ?>Create reactive elements:
<p>Count: <?= $this->Spa->target('count', $count) ?></p>
<?= $this->Spa->button('Increment', '/counter/increment') ?>See the CakeSPA documentation for more details.
This starter kit includes DbConfig for storing application configuration in the database.
Run the DbConfig migrations:
bin/cake migrations migrate --plugin DbConfigAccess the configuration dashboard at /db-config/app-settings. Configuration values are automatically loaded and accessible via CakePHP's Configure::read().
See the DbConfig documentation for more details.
Contributions, issues, and feature requests are welcome!
This project is available as open source under the terms of the MIT License.