sonypradana / php-mvc
Very light php mvc, include cli easyer to creat controller view and model quikly
Installs: 53
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.0
- react/event-loop: ^1.5
- sonypradana/php-library: ^0.36
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- filp/whoops: ^2.15
- friendsofphp/php-cs-fixer: ^3.59
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^9.6 || ^10.0
- v2.0.x-dev
- v2.0.0-rc
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta.1
- v1.1.x-dev
- v1.1.0
- v1.1.0-beta.2
- v1.1.0-beta.1
- v1.0.x-dev
- v1.0.0
- v1.0.0-beta.10
- v1.0.0-beta.9
- v1.0.0-beta.8
- v1.0.0-beta.7
- v1.0.0-beta.6
- v1.0.0-beta.5
- v1.0.0-beta.4
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- dev-master / 0.x-dev
- v0.2.x-dev
- v0.2.1
- v0.2.0
- v0.1.x-dev
- v0.1.6
- v0.1.5
- 0.1
- dev-dev
This package is auto-updated.
Last update: 2024-12-28 02:07:21 UTC
README
PHP MVC
Welcome to php-mvc, a minimal MVC framework designed to streamline your PHP development process. This lightweight framework offers essential features for building web applications while maintaining simplicity and ease of use.
php-library version 0.33 now end support for php 7.4. If you strill using php 7.4 use php-library 0.32.x, this version still accept bug and security update (small feature for improving performance).
Feature
- MVC structure
- Application Container (power with php-di)
- Router Support
- Models builder
- Query builder
- CLI command
- Service Provider and Middleware
- Templator (template engine)
Getting Started in 4 Simple Steps
- Create Your Application:
composer create-project sonypradana/php-mvc project-name
- Navigate to Your Project:
cd project-name
- Build Your Assets:
npm install npm run build
- Serve Your Application:
php cli serve
Additional Features ✨
CLI Commands for Building Your App
# Create migration schema php cli make:migration profiles php cli db:create # skip if database already exists php cli migrate # Create a model php cli make:model Profile --table-name profiles # Create controller (or API services) php cli make:controller Profile php cli make:services Profile # Presenter for HTML response php cli make:view profile
Example Code Snippets
Migration Schema
// database/migration/<timestamp>_profile.php Schema::table('profiles', function (Create $column) { $column('user')->varChar(32); $column('real_name')->varChar(100); $column->primaryKey('user'); });
Controller
// app/Controller/ProfileController.php public function index(MyPDO $pdo): Response { return view('profiles', [ 'name' => Profile::find('pradana', $pdo)->real_name ]); }
Services (rest api out of the box)
Api ready to go http://localhost:8080/api/profile/index
.
// app/services/ProfileServices.php public function index(MyPDO $pdo): array { return [ 'name' => Profile::find('pradana', $pdo)->real_name, 'status' => 200, 'header' => [] ]; }
View
// resources/views/profile.template.php {% extend('base/base.template.php') %} {% section('title', 'hay {{ $name }}') %} {% section('content') %} <p>{{ $name }}</p> {% endsection %}
Router Configuration
// route/web.php Router::get('/profile', Profile::class);
Optimize
Optimeze by cached Application.
# cache view compiler php cli view:cache # cache application config php cli config:cache
License
php-mvc is open-source software licensed under the MIT license.