phantom-php / framework
A minimalist but powerful PHP framework
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/phantom-php/framework
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.0
README
Phantom is a minimalist, elegant, and fast PHP framework, designed for developers seeking Laravel's structure with the lightness of a micro-framework.
Main Features
- 📦 IoC Container: Simple and powerful dependency management.
- 🛣️ Advanced Routing: Route Groups, Named Routes, Middlewares, and Controllers.
- 🛡️ Native Security: CSRF protection, data validation, and hashing with Argon2/Bcrypt.
- 🗄️ Phantom ORM: Fluent Query Builder and Active Record model.
- 🎨 View Engine: Clean and efficient native PHP template system.
- 🌐 Internationalization: Built-in multi-language support.
- 💻 Phantom CLI: Command line interface for automation and code generation.
- ✉️ Mail System: Integrated email sending system.
- 📁 File Storage: File management with advanced security validation (MIME + Magic Numbers).
- 🌱 Seeders & Factories: System for populating the database with test data.
- 📝 Advanced Logging: Automatic error recording in local logs.
- 🎨 Elegant Error Handling: Custom Tailwind CSS error views and refined debug mode.
Requirements
- PHP 8.1 or superior.
- Extensions: PDO, OpenSSL, Mbstring, Fileinfo.
Quick Installation
- Clone the repository.
- Run
composer install. - Copy
.env.exampleto.envand configure your credentials. - Start your server:
php -S localhost:8000 -t public.
Basic Usage
Defining a Route
// routes/web.php use Phantom\Core\Router; // Simple Route $router->get('/hello', function() { return view('welcome', ['name' => 'User']); })->name('hello'); // Route Group with Prefix and Middleware $router->group(['prefix' => 'admin', 'middleware' => 'auth'], function(Router $router) { $router->get('/dashboard', [AdminController::class, 'index'])->name('admin.dashboard'); }); // Generating URLs $url = route('admin.dashboard');
Using the ORM
$users = User::where('active', 1)->get();
Phantom CLI
The framework includes a powerful command-line interface. You can run it using the phantom binary in the project root:
General Commands
# List all available commands php phantom list # See current framework version php phantom version
Database Management
# Run migrations php phantom migrate # Rollback last migration php phantom migrate:rollback # Seed the database php phantom db:seed
Code Generation (Scaffolding)
# Create a new migration php phantom make:migration create_posts_table # Create a new model php phantom make:model Post # Create a new controller php phantom make:controller PostController # Create a new view (supports dot notation) php phantom make:view posts.index # Create a new seeder php phantom make:seeder PostSeeder
License
This project is under the MIT License.
Designed with ❤️ for speed and elegance.