PHPackages                             phastasf/app - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. phastasf/app

ActiveProject[Framework](/categories/framework)

phastasf/app
============

A skeleton application for Phast Framework - a lightweight, modern PHP framework built on PSR standards

1.1(3mo ago)31MITHTMLPHP ^8.2

Since Jan 2Pushed 3mo agoCompare

[ Source](https://github.com/phastasf/app)[ Packagist](https://packagist.org/packages/phastasf/app)[ RSS](/packages/phastasf-app/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Phast Framework Skeleton
========================

[](#phast-framework-skeleton)

A skeleton application for [Phast Framework](https://github.com/phastasf/framework) - a lightweight, modern PHP framework built on PSR standards.

Features
--------

[](#features)

This skeleton application provides a clean starting point for building applications with Phast Framework, including:

- ✅ **PSR Standards**: Full compliance with PSR-7, PSR-11, PSR-15, PSR-3, PSR-6, PSR-16, and PSR-20
- ✅ **Routing**: Example routes demonstrating controller actions and closures
- ✅ **Controllers**: Base controller with helper methods for rendering views, JSON responses, and redirects
- ✅ **Views**: Template rendering with Phew template engine
- ✅ **Console Commands**: CLI entrypoint for running console commands
- ✅ **Error Handling**: Centralized exception handling
- ✅ **Dependency Injection**: Service container integration
- ✅ **Docker Support**: Complete Docker setup with Traefik, MySQL, Redis, and development tools
- ✅ **Frontend Tooling**: Vite + React setup with hot module replacement and production builds
- ✅ **Seeders**: Generate and run seeders for development and testing data

Requirements
------------

[](#requirements)

- Docker and Docker Compose
- [mkcert](https://github.com/FiloSottile/mkcert) for local SSL certificates
- PHP 8.2 or higher (for local development without Docker)
- Node.js 22+ and Yarn (for frontend development)

Installation
------------

[](#installation)

Setup project:

```
# create new project
composer create-project phastasf/app my-app

# go into project dir
cd my-app

# create .env file
cp .env.example .env
```

Create SSL certificates:

```
mkcert local.dev '*.local.dev' localhost 127.0.0.1 ::1
```

This will create certificate files (`local.dev+4.pem` and `local.dev+4-key.pem`) in the project root.

Add hostnames to `/etc/hosts`:

```
sudo nano /etc/hosts
```

Add the following lines:

```
127.0.0.1 web.local.dev
127.0.0.1 api.local.dev
127.0.0.1 phpmyadmin.local.dev
127.0.0.1 mailcatcher.local.dev
127.0.0.1 redis-insight.local.dev

```

Start services:

```
docker compose up -d
```

Usage
-----

[](#usage)

### Available Services

[](#available-services)

Once the Docker services are running, you can access:

- **Frontend (Vite Dev Server)**:
- **Backend API**:
- **Traefik Dashboard**:
- **phpMyAdmin**:
- **MailCatcher**:
- **Redis Insight**:

### Example Routes

[](#example-routes)

- `GET /` - Home page (renders welcome view)
- `GET /health` - Health check endpoint
- `GET /error` - Error handling test route
- `GET /api/status` - API status endpoint (example of route groups)

### Docker Services

[](#docker-services)

The Docker Compose setup includes:

- **web** - Node.js 22 container running Vite dev server for frontend development
- **api** - PHP 8.5 Apache container running the backend API
- **worker** - Queue worker container
- **mysql** - MySQL 8 database server
- **redis** - Redis 5 cache and queue backend
- **traefik** - Reverse proxy with automatic HTTPS
- **phpmyadmin** - Database management interface
- **mailcatcher** - Email testing tool
- **redis-insight** - Redis management interface

Structure
---------

[](#structure)

The project structure is as explained below:

```
phast-app/
├── app/
│   ├── Commands/            # Console commands
│   ├── Controllers/         # Application controllers
│   ├── Events/              # Event classes
│   ├── Jobs/                # Queue jobs
│   ├── Middleware/          # Custom middleware
│   ├── Models/              # Database models
│   └── Providers/           # Service providers
├── config/                  # Configuration files (optional overrides)
├── database/
│   ├── migrations/          # Database migrations
│   └── seeders/             # Database seeders (development/testing)
├── .docker/                 # Docker configuration files
│   └── vhost.conf           # Apache virtual host configuration
├── public_html/             # Web server document root
│   ├── index.php            # Web entrypoint
│   ├── .htaccess             # Apache rewrite rules
│   ├── assets/              # Built frontend assets (JS, CSS, images)
│   └── index.html           # Built HTML entry point (generated by Vite)
├── resources/
│   ├── assets/             # Frontend source files (Vite + React)
│   │   ├── App.tsx         # Main React component
│   │   ├── App.css         # Component styles
│   │   ├── index.html      # HTML entry point
│   │   ├── index.css       # Global styles
│   │   └── main.tsx        # React entry point
│   └── views/              # View templates
├── routes/
│   └── web.php              # Route definitions
├── storage/
│   ├── cache/               # Application cache
│   │   ├── app/             # Application-specific cache
│   │   ├── config.php       # Cached configuration
│   │   └── routes.php       # Cached routes
│   └── logs/                # Log files
├── console                  # CLI entrypoint
├── docker-compose.yml       # Docker Compose configuration
├── Dockerfile               # Multi-stage build (Node + PHP)
├── traefik.yml              # Traefik configuration
├── vite.config.ts           # Vite configuration
├── package.json             # Node.js dependencies and scripts
├── tsconfig.json            # TypeScript configuration
├── tsconfig.app.json        # TypeScript config for app
├── tsconfig.node.json       # TypeScript config for Node
├── eslint.config.js         # ESLint configuration
├── composer.json            # PHP dependencies
└── yarn.lock                # Yarn lock file

```

Console Commands
----------------

[](#console-commands)

### Generators

[](#generators)

#### Create command

[](#create-command)

Generate a new console command:

```
docker compose exec web php console g:command CreateUser
```

#### Create controller

[](#create-controller)

Generate a new controller:

```
docker compose exec web php console g:controller UserController
```

#### Create model

[](#create-model)

Generate a new model:

```
docker compose exec web php console g:model User
```

#### Create migration

[](#create-migration)

Generate a new migration:

```
docker compose exec web php console g:migration create_users_table
```

#### Create job

[](#create-job)

Generate a new job class:

```
docker compose exec web php console g:job SendEmail
```

#### Create event

[](#create-event)

Generate a new event class:

```
docker compose exec web php console g:event UserRegistered
```

#### Create middleware

[](#create-middleware)

Generate a new middleware class:

```
docker compose exec web php console g:middleware CustomMiddleware
```

#### Create service provider

[](#create-service-provider)

Generate a new service provider:

```
docker compose exec web php console g:provider CustomService
```

#### Create seeder

[](#create-seeder)

Generate a new seeder class (for development/testing data):

```
docker compose exec web php console g:seeder UserSeeder
```

### Database

[](#database)

#### Run migrations

[](#run-migrations)

Run pending migrations:

```
docker compose exec web php console m:up
```

#### Rollback migrations

[](#rollback-migrations)

Rollback migrations (default: 1):

```
docker compose exec web php console m:down
```

Rollback multiple migrations:

```
docker compose exec web php console m:down 3
```

#### Run seeders

[](#run-seeders)

Run database seeders (only those listed in `config/database.php` under `seed`):

```
docker compose exec web php console seed
```

### Development

[](#development)

#### Start development server

[](#start-development-server)

Start the development server:

```
docker compose exec web php console serve
```

#### Run queue worker

[](#run-queue-worker)

Start a queue worker:

```
docker compose exec worker php console worker
```

#### Interactive shell

[](#interactive-shell)

Start an interactive PHP shell (REPL) with container access:

```
docker compose exec web php console shell
```

#### Clear cache

[](#clear-cache)

Clear cached config, routes, and application cache:

```
docker compose exec web php console uncache
```

Configuration
-------------

[](#configuration)

Configuration files can be placed in the `config/` directory to override framework defaults. The framework loads default configurations from the package and merges your project-specific overrides.

Environment variables are configured in the `.env` file. The `.env.example` file includes default values configured for the Docker setup:

- Database connection uses `mysql` as hostname (Docker service name)
- Redis connection uses `redis` as hostname (Docker service name)
- All services are accessible via `.local.dev` domain with SSL certificates

### Middleware

[](#middleware)

Middleware allows you to intercept and modify HTTP requests and responses. Create a custom middleware using the generator:

```
docker compose exec web php console g:middleware CustomMiddleware
```

This will create a middleware in `app/Middleware/` that implements `Psr\Http\Server\MiddlewareInterface`.

The `config/middleware.php` file is automatically copied from the framework during `composer install` or `composer update` if it doesn't exist. This file defines the middleware pipeline that processes HTTP requests:

```
