nanophp / framework
The core framework for NanoPHP
Installs: 0
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nanophp/framework
Requires
- php: >=8.1
- dragonmantank/cron-expression: ^3.6
- illuminate/container: ^11.0
- illuminate/database: ^11.0
- illuminate/events: ^11.0
- illuminate/filesystem: ^11.0
- illuminate/translation: ^11.0
- illuminate/validation: ^11.0
- illuminate/view: ^11.0
- laminas/laminas-diactoros: ^3.0
- laminas/laminas-httphandlerrunner: ^2.0
- league/flysystem: ^3.0
- monolog/monolog: ^3.10
- nikic/fast-route: ^1.3
- php-di/php-di: ^7.0
- psr/http-server-middleware: ^1.0
- symfony/console: ^7.4
- symfony/process: ^7.4
- vlucas/phpdotenv: ^5.6
This package is auto-updated.
Last update: 2026-02-03 15:31:27 UTC
README
NanoPHP Framework Core
The powerful engine behind NanoPHP applications
๐ฆ About
This is the core framework package for NanoPHP. It provides the foundational components that power NanoPHP applications, including:
- Routing Engine - Fast route matching with FastRoute
- Dependency Injection - Powerful DI container with PHP-DI
- Middleware Pipeline - PSR-15 compliant middleware processing
- View Engine - Blade template compilation and rendering
- Authentication System - Session-based authentication with guards
- Database Integration - Eloquent ORM and query builder
- Validation - Comprehensive request validation
- Console Commands - 50+ built-in Artisan commands
- Logging - Monolog-based logging system
- Facades - Laravel-style static proxies
๐๏ธ Architecture
Core Components
framework/
โโโ src/
โ โโโ Application.php # Application kernel
โ โโโ Router.php # Route management
โ โโโ Facade.php # Facade base class
โ โโโ View.php # View rendering
โ โโโ Auth.php # Authentication
โ โโโ Database.php # Database bootstrapping
โ โโโ LogManager.php # Logging
โ โโโ AI.php # AI integration
โ โโโ Auth/ # Auth components
โ โ โโโ SessionGuard.php
โ โ โโโ Gate.php
โ โโโ Console/ # Artisan commands
โ โ โโโ Commands/
โ โ โโโ Kernel.php
โ โโโ Facades/ # Static facades
โ โ โโโ Route.php
โ โ โโโ View.php
โ โ โโโ Auth.php
โ โโโ Middleware/ # Core middleware
โ โ โโโ CsrfMiddleware.php
โ โ โโโ TrimStrings.php
โ โ โโโ SecurityHeadersMiddleware.php
โ โโโ Http/ # HTTP components
โ โ โโโ Request.php
โ โโโ Filesystem/ # Storage management
โ โโโ Cache/ # Caching system
โ โโโ CoreDefinitions.php # DI definitions
โ โโโ helpers.php # Global helpers
โโโ composer.json
๐ง Installation
This package is automatically installed when you create a NanoPHP application:
composer create-project nanophp/nanophp my-project --stability=dev
Or add it to an existing project:
composer require nanophp/framework:dev-main
๐ฏ Key Features
1. Powerful Routing
use Nano\Framework\Facades\Route; Route::get('/users/{id}', 'UserController@show'); Route::post('/users', 'UserController@store')->middleware('auth');
2. Dependency Injection
// Automatic constructor injection class UserController { public function __construct( private UserRepository $users, private Logger $log ) {} }
3. Blade Templates
@extends('layouts.app') @section('content') <h1>{{ $title }}</h1> @foreach($users as $user) <p>{{ $user->name }}</p> @endforeach @endsection
4. Eloquent ORM
// Elegant database queries $users = User::where('active', true) ->with('posts') ->orderBy('created_at', 'desc') ->get();
5. Authentication
use Nano\Framework\Facades\Auth; // Login Auth::attempt($credentials); // Check authentication if (Auth::check()) { $user = Auth::user(); } // Logout Auth::logout();
๐ ๏ธ Console Commands
The framework provides 50+ Artisan commands:
Generators
make:controller- Create a new controllermake:model- Create a new modelmake:middleware- Create middlewaremake:migration- Create database migrationmake:seeder- Create database seedermake:auth- Scaffold authentication
Database
migrate- Run migrationsmigrate:rollback- Rollback migrationsmigrate:fresh- Drop all tables and re-run migrationsdb:seed- Seed the database
Cache & Optimization
cache:clear- Clear application cacheview:clear- Clear compiled viewsconfig:cache- Cache configuration
Development
serve- Start development servertinker- Interactive REPL
๐ Integration with Illuminate
NanoPHP leverages battle-tested Laravel components:
- illuminate/database - Eloquent ORM and Query Builder
- illuminate/validation - Request validation
- illuminate/view - Blade template engine
- illuminate/filesystem - File operations
- illuminate/translation - Localization
- illuminate/events - Event dispatcher
๐ Helper Functions
The framework provides Laravel-style global helpers:
// Views view('welcome', ['name' => 'John']); // Routing route('user.profile', ['id' => 1]); // JSON responses json(['status' => 'success']); // Environment env('APP_ENV', 'production'); // Paths base_path('config/app.php'); storage_path('logs/app.log'); // String helpers str_slug('Hello World'); // hello-world str_random(16); // Array helpers array_get($array, 'key.nested', 'default');
๐๏ธ Design Patterns
NanoPHP implements industry-standard patterns:
- Dependency Injection - Loose coupling, testable code
- Facade Pattern - Clean, expressive syntax
- Repository Pattern - Data access abstraction
- Middleware Pattern - Request/response filtering
- Service Container - Automatic dependency resolution
- PSR Standards - PSR-7, PSR-11, PSR-15 compliant
๐งช Testing
The framework is designed for testability:
use PHPUnit\Framework\TestCase; class UserTest extends TestCase { public function test_user_creation() { $user = User::create([ 'name' => 'John Doe', 'email' => 'john@example.com' ]); $this->assertEquals('John Doe', $user->name); } }
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
๐ License
The NanoPHP Framework is open-sourced software licensed under the MIT license.
๐ Acknowledgments
- Laravel - For inspiring our architecture and design philosophy
- Illuminate Components - For providing robust, well-tested components
- PHP-DI - For powerful dependency injection
- FastRoute - For blazing-fast routing
- Symfony Console - For the command-line interface
Built with โค๏ธ for the PHP community
