Skip to main content

Development Setup

This guide will help you set up a local development environment for TorrentPier.

Prerequisites

  • Git
  • PHP 8.4+
  • Composer
  • Node.js 22+
  • MySQL/PostgreSQL
  • Redis (optional)

Quick Start

1. Clone and Install

# Clone the repository
git clone https://github.com/torrentpier/torrentpier.git
cd torrentpier

# Install dependencies
composer install
npm install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

2. Database Setup

# Create database
mysql -u root -p -e "CREATE DATABASE torrentpier"

# Run migrations
php artisan migrate

# Seed with sample data (optional)
php artisan db:seed

3. Start Development Server

# Start Laravel and Vite development servers
composer dev

This runs both the PHP server and Vite dev server concurrently.

Development Tools

Laravel Telescope

Telescope is pre-installed for debugging:

# Access at http://localhost:8000/telescope

Code Quality Tools

# PHP code style
./vendor/bin/pint

# JavaScript/TypeScript linting
npm run lint

# Format code
npm run format

# Type checking
npm run types

Testing

# Run all tests
composer test

# Run specific test
php artisan test --filter=ExampleTest

# Run with coverage
php artisan test --coverage

IDE Setup

VS Code

Recommended extensions:

  • Laravel Extension Pack
  • Inertia.js
  • Tailwind CSS IntelliSense
  • ESLint
  • Prettier

PHPStorm

  • Install Laravel plugin
  • Configure code style to use Pint
  • Set up Pest integration

Working with Artisan

Always Use Artisan Commands

# Generate model with all resources and API controller
php artisan make:model Post --all --api

# Create controller
php artisan make:controller PostController --resource

Useful Commands

# Clear all caches
php artisan optimize:clear

# Show routes
php artisan route:list

# Show model details
php artisan model:show User

# Interactive tinker shell
php artisan tinker

Frontend Development

Creating Pages

  1. Create page component in resources/js/pages/
  2. Define route in routes/web.php
  3. Return Inertia response from controller

Example:

// routes/web.php
Route::get('/posts', [PostController::class, 'index'])->name('posts.index');

// app/Http/Controllers/PostController.php
public function index()
{
return Inertia::render('Posts/Index', [
'posts' => Post::paginate()
]);
}
// resources/js/pages/Posts/Index.tsx
import { Head } from '@inertiajs/react';

export default function Index({ posts }) {
return (
<>
<Head title="Posts" />
<div>
{/* Your component */}
</div>
</>
);
}

Using shadcn/ui Components

import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';

export default function MyComponent() {
return (
<Card>
<Button>Click me</Button>
</Card>
);
}

Database Development

Migrations

# Create migration
php artisan make:migration create_posts_table

# Run migrations
php artisan migrate

# Rollback
php artisan migrate:rollback

# Fresh migration with seed
php artisan migrate:fresh --seed

Working with Models

// Use artisan to generate models
php artisan make:model Post -mfsc

// This creates:
// - Model: app/Models/Post.php
// - Migration: database/migrations/xxx_create_posts_table.php
// - Factory: database/factories/PostFactory.php
// - Seeder: database/seeders/PostSeeder.php
// - Controller: app/Http/Controllers/PostController.php

Troubleshooting

Common Issues

  1. npm install fails
   rm -rf node_modules package-lock.json
npm install
  1. Composer memory limit
   COMPOSER_MEMORY_LIMIT=-1 composer install
  1. Permission errors
   chmod -R 775 storage bootstrap/cache
  1. Cache issues
   php artisan optimize:clear