Get 20% off web development packages
Laravel Installation & Setup: Professional Development Environment
Laravel Installation & Setup: Professional Development Environment
Expert Guide by Alaa Amer – Professional Web Developer & Applications Designer
Setting up Laravel properly is crucial for productivity and project success. Learn how to create a robust development environment that scales with your needs.
2️⃣ Installation Methods Comparison
Method 1: Laravel Installer (Recommended)
# Install Laravel Installer globally
composer global require laravel/installer
# Make sure composer global bin is in your PATH
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Create new Laravel project
laravel new my-awesome-app
# Advanced installation with options
laravel new my-awesome-app --git --branch=main --pest --dark
# Navigate to project
cd my-awesome-app
# Start development server
php artisan serve
Method 2: Composer Create-Project
# Create project via Composer
composer create-project laravel/laravel my-awesome-app
# Install specific Laravel version
composer create-project laravel/laravel:^10.0 my-awesome-app
# With additional flags
composer create-project laravel/laravel my-awesome-app --prefer-dist
Method 3: Docker Development Environment
# docker-compose.yml for Laravel development
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
container_name: laravel-app
restart: unless-stopped
working_dir: /var/www/html
volumes:
- .:/var/www/html
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/laravel.ini
networks:
- laravel-network
depends_on:
- database
- redis
webserver:
image: nginx:alpine
container_name: laravel-nginx
restart: unless-stopped
ports:
- "8080:80"
volumes:
- .:/var/www/html
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- laravel-network
depends_on:
- app
database:
image: mysql:8.0
container_name: laravel-mysql
restart: unless-stopped
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/custom.cnf
ports:
- "3306:3306"
networks:
- laravel-network
redis:
image: redis:7-alpine
container_name: laravel-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- laravel-network
node:
image: node:20-alpine
container_name: laravel-node
working_dir: /var/www/html
volumes:
- .:/var/www/html
command: npm run dev
networks:
- laravel-network
volumes:
mysql_data:
driver: local
redis_data:
driver: local
networks:
laravel-network:
driver: bridge
4️⃣ Essential Packages & Tools Installation
Development Dependencies:
# Install development packages
composer require --dev laravel/telescope
composer require --dev barryvdh/laravel-debugbar
composer require --dev laravel/pint
composer require --dev pestphp/pest
composer require --dev pestphp/pest-plugin-laravel
composer require --dev spatie/laravel-ignition
composer require --dev nunomaduro/collision
# Publish Telescope assets
php artisan telescope:install
php artisan migrate
# Install Laravel Pint for code formatting
./vendor/bin/pint
# Install Pest for testing
./vendor/bin/pest --init
Production Packages:
# Essential production packages
composer require laravel/sanctum
composer require spatie/laravel-permission
composer require spatie/laravel-backup
composer require spatie/laravel-activitylog
composer require intervention/image
composer require maatwebsite/excel
composer require barryvdh/laravel-dompdf
composer require pusher/pusher-php-server
# Install and configure Sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
# Install Spatie Permission
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
Frontend Development Setup:
# Install Node.js dependencies
npm install
# Install additional frontend tools
npm install -D @tailwindcss/forms @tailwindcss/typography
npm install -D autoprefixer postcss
npm install -D @vitejs/plugin-vue
npm install alpinejs
npm install axios
# Install UI framework (choose one)
npm install bootstrap
# or
npm install @headlessui/vue @heroicons/vue
# or
composer require laravel/breeze --dev
php artisan breeze:install vue
Database Seeding Setup:
<?php
// database/seeders/DatabaseSeeder.php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
// Create admin user
\App\Models\User::factory()->create([
'name' => 'Admin User',
'email' => '[email protected]',
'email_verified_at' => now(),
'is_admin' => true,
]);
// Create test users
\App\Models\User::factory(10)->create();
// Seed other data
$this->call([
RoleAndPermissionSeeder::class,
CategorySeeder::class,
PostSeeder::class,
]);
}
}
// Run seeders
php artisan db:seed
6️⃣ Performance Optimization Setup
Config Caching Strategy:
# Development environment
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
# Production environment
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
Database Optimization:
<?php
// config/database.php - Optimized MySQL configuration
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::ATTR_TIMEOUT => 5,
PDO::ATTR_EMULATE_PREPARES => false,
]) : [],
'dump' => [
'dump_binary_path' => '/usr/bin', // Path to mysqldump
'use_single_transaction' => true,
'timeout' => 60 * 5, // 5 minutes
],
],
💡 Troubleshooting Common Issues
Permission Issues (Linux/Mac):
# Fix storage permissions
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Composer Issues:
# Clear Composer cache
composer clear-cache
# Update Composer itself
composer self-update
# Install with verbose output
composer install -vvv
Environment Issues:
# Regenerate app key
php artisan key:generate
# Clear all caches
php artisan optimize:clear
# Rebuild autoload files
composer dump-autoload
Next Steps
Ready for the next level? Learn Understanding MVC Pattern in Laravel to master the architectural foundation.
📩 Need help with Laravel installation?
Article Category
Laravel Installation & Setup: Professional Development Environment
Complete guide to installing and configuring Laravel for professional development with modern tools, best practices, and optimization techniques.
Consultation & Communication
Direct communication via WhatsApp or phone to understand your project needs precisely.
Planning & Scheduling
Creating clear work plan with specific timeline for each project phase.
Development & Coding
Building projects with latest technologies ensuring high performance and security.
Testing & Delivery
Comprehensive testing and thorough review before final project delivery.
Services Related to This Article
All ServicesWant to apply this article to your project?
If this topic is relevant to your current project, you can jump to one of the services above or browse the services page to choose the most suitable solution.