This is the Moon Pixels skeleton for building Laravel applications with Inertia and React. This project serves as a starting point for new Laravel applications with a modern frontend setup and enhanced development tools.
This skeleton provides several enhancements over a standard Laravel application:
- Laravel 12.0 with PHP 8.4 support
- PostgreSQL database integration
- Redis for caching, session management, and queue processing
- Laravel Horizon for queue monitoring and management
- Laravel Reverb for WebSockets support
- MinIO integration for S3-compatible object storage
- Two-factor authentication support via Google2FA
- Advanced image processing with Intervention Image and Imagick
- React 19 with TypeScript for the frontend
- Inertia.js for connecting Laravel with React without building an API
- Tailwind CSS 4 for styling
- Radix UI components for accessible UI elements
- React Hook Form for form handling with Zod validation
- Laravel Echo for real-time features
- PHPStan for static analysis of PHP code
- Laravel Pint for PHP code styling
- Rector for automatic PHP code refactoring
- Pest for PHP testing with coverage reports
- ESLint for JavaScript/TypeScript linting
- Prettier for JavaScript/TypeScript code formatting
- Vite for fast frontend builds
- Laravel Debugbar and Laravel Telescope for debugging
The project uses Laravel Herd for local development. Laravel Herd provides a lightweight, native development environment for macOS.
- Install Laravel Herd on your Mac
- Make sure Herd is running
-
Clone the repository and cd into the project directory
git clone [email protected]:moonpixels/laravel-skeleton-react.git && cd laravel-skeleton-react
-
Install the PHP dependencies
composer install
-
Copy the
.env.example
file to.env
and update the environment variablescp .env.example .env
-
Generate the application key
php artisan key:generate
-
Initialize Herd for the project
herd init
-
Run the migrations and seed the database
php artisan migrate:fresh --seed
-
Install the NPM dependencies
npm install
-
Build the assets
npm run build
-
Run the tests to ensure everything is working
composer test
If the tests pass, you should be good to go.
Once you have the project set up, you may also want to perform the following post-installation steps:
You can start the development server by running:
npm run dev
The application should now be available at http://skeleton.test (or the URL you configured in
your .env
file).
This project uses MinIO for S3-compatible object storage. You need to create a bucket in MinIO that matches the bucket
name in your .env
file:
- Access the MinIO dashboard at https://minio.herd.test using the credentials from your
.env
file (default: usernameherd
, passwordsecretkey
) - Create a new bucket with the name specified in your
.env
file (default:skeleton
) - Set the bucket's access policy to "public" if you want files to be publicly accessible
There are several composer scripts available for maintaining code quality:
# Run Rector automatic refactoring
composer rector
# Run Pint code styling
composer pint
# Run PHPStan static analysis
composer stan
# Run Pest tests
composer test
# Run tests with coverage reports
composer coverage
# Check type coverage
composer type-coverage
# Optimize class autoloading
composer dump
# Run all checks (including code coverage)
composer checks
You should always run
composer checks
before pushing your code. This will ensure that your code is clean and passes all checks that are enforced by the project CI/CD pipeline.
There are also npm scripts available for maintaining frontend code quality:
# Run ESLint static analysis
npm run lint
# Run Prettier code styling
npm run format
# Run all checks
npm run checks
You should always run
npm run checks
before pushing your code. This will ensure that your code is clean and passes all checks that are enforced by the project CI/CD pipeline.
This project follows a set of coding practices and conventions to ensure code quality, maintainability, and consistency.
- Strict Types: All PHP files use
declare(strict_types=1);
to enforce strict type checking - Final Classes: Classes are marked as
final
by default to prevent inheritance unless specifically designed for extension - Action Pattern: Business logic is encapsulated in single-purpose Action classes
- Data Transfer Objects (DTOs): Used for passing structured data between components
- Type Declarations: All method parameters and return types are explicitly typed
- Private Over Protected: Class members are private by default to enforce encapsulation
- Imports Over Namespaces: Classes are imported with
use
statements rather than using fully qualified namespaces - PHPDoc Blocks: Used for documenting exceptions, and complex parameters / return types that use generics
- Dependency Injection: Constructor injection is used for dependencies
- Value Objects: Used for encapsulating domain concepts
- Enums: Used for representing a fixed set of related values
- TypeScript: Used throughout with strict type checking
- Functional Components: React components are written as functional components with hooks
- Zod Validation: Form validation is handled with Zod schemas
- React Hook Form: Used for form state management
- Component Composition: UI is built from small, reusable components
- Internationalization: All user-facing strings are internationalized
- Import Aliases: Used for better organization and shorter import paths
- Explicit Typing: Function parameters and returns are explicitly typed
- Async/Await: Used for handling asynchronous operations
- Toast Notifications: Used for user feedback
- Context API: Used for global state management
The project includes a basic GitHub Actions workflow for CI/CD in the .github/workflows
directory. You may need to
customize this for your specific deployment needs.
This project is proprietary software. See the LICENSE file for more information.