Below is a step-by-step guide to scaffold a fresh Laravel 10 project, install/configure PHP-CS-Fixer, Larastan, PHP Insights, and ESLint, and add a GitHub Actions workflow to run them on every push. Feel free to copy these files into your Git repo once you’ve shared access.
1. Create the Laravel Project
# 1.1 Install Laravel (if not already installed)
composer global require laravel/installer
# 1.2 Create project
laravel new base-product
cd base-product
2. Install Dev Dependencies
# PHP code style & static analysis
composer require --dev friendsofphp/php-cs-fixer nuno-m/larastan roave/phpinsights
# (Optional) If using Laravel Sail or Docker, adjust accordingly
3. Configure PHP-CS-Fixer
Create a file at .php-cs-fixer.dist.php:
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = Finder::create()
->in([
__DIR__ . '/app',
__DIR__ . '/routes',
__DIR__ . '/modules', // if you later add modules
__DIR__ . '/packages', // shared packages
])
->exclude(['storage', 'bootstrap/cache', 'vendor']);
return (new Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'single_quote' => true,
'no_trailing_comma_in_singleline_array' => true,
])
->setFinder($finder);
Add in composer.json under "scripts":
"scripts": {
"fix": "php-cs-fixer fix --config=.php-cs-fixer.dist.php",
"fix:dry": "php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run --diff"
}
Run once to verify:
composer fix:dry
composer fix
4. Configure Larastan (PHPStan)
Create phpstan.neon at project root:
includes:
- vendor/nunomaduro/larastan/extension.neon
parameters:
level: max # or set 5–8 for a softer start
paths:
- app
- modules # if applicable
- packages # if applicable
excludePaths:
analyse:
- */vendor/*
- */storage/*
Add to composer.json:
"scripts": {
"analyse": "phpstan analyse"
}
Verify:
composer analyse
5. Configure PHP Insights
Create phpinsights.php (or phpinsights.json) at project root:
<?php
return [
'preset' => 'laravel',
'exclude' => [
'bootstrap',
'storage',
'vendor',
],
'add' => [],
'remove' => [
'phpdoc_annotation_without_dot',
'phpdoc_summary',
],
'config' => [
'min-quality' => 80,
'min-complexity' => 10,
'min-architecture' => 85,
'min-style' => 85,
'min-security' => 80,
],
];
Add in composer.json:
"scripts": {
"insights": "phpinsights"
}
Run:
composer insights
6. Initialize & Configure ESLint
# 6.1 Initialize npm
npm init -y
# 6.2 Install ESLint
npm install --save-dev eslint
# 6.3 Create ESLint config
npx eslint --init
# • Choose “To check syntax and find problems”
# • Pick “JavaScript modules (import/export)”
# • Framework: “None of these”
# • Format: JSON
# • Where: Choose your .js/.vue/.jsx files
It will generate .eslintrc.json. Example minimal config:
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"no-unused-vars": "warn",
"semi": ["error", "always"],
"quotes": ["error", "single"]
}
}
Add in package.json:
"scripts": {
"lint:js": "eslint resources/js --ext .js,.vue"
}
Run:
npm run lint:js
7. HTML Validation
You can add HTMLHint if you want:
npm install --save-dev htmlhint
Create .htmlhintrc:
{
"tagname-lowercase": true,
"attr-lowercase": true,
"doctype-first": true,
"tag-pair": true,
"attr-value-double-quotes": true
}
Add in package.json:
"scripts": {
"lint:html": "htmlhint resources/views/**/*.blade.php"
}
Run:
npm run lint:html
8. GitHub Actions Workflow
Create .github/workflows/ci.yml:
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
php:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: base_product_test
ports: ['3306:3306']
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v3
- name: Setup PHP, Extensions & Composer
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, bcmath, tokenizer, xml, ctype, curl, json, sqlite
tools: composer:v2
- name: Install Dependencies
run: |
composer install --prefer-dist --no-progress --no-suggest
npm ci
- name: Prepare .env
run: |
cp .env.example .env
php artisan key:generate
php artisan migrate --force
- name: Run PHP-CS-Fixer
run: composer fix:dry
- name: Run Larastan
run: composer analyse
- name: Run PHP Insights
run: composer insights
- name: Run PHPUnit Tests
run: vendor/bin/phpunit --testsuite=Unit
- name: Run ESLint
run: npm run lint:js
- name: Run HTMLHint
run: npm run lint:html
9. Next Steps
- Commit & Push all files to your Git repository.
- Give me repo access (e.g., add my GitHub user as collaborator).
- GitHub Actions will auto-run on your next push.
Once CI is green, we’ll proceed to:
- Set up the
Core module (Users, Auth, Tenancy).
- Build the
AdminPortal module (RBAC, dashboard).
- Scaffold
Booking and Products/{Salon,Doctor,…} modules.
Let me know when you’ve pushed and granted access—and we’ll dive into the core setup! 🚀