webpagestudio/wps-micro
Composer 安装命令:
composer require webpagestudio/wps-micro
包简介
Skeleton for web apps with MVC pattern
README 文档
README
Small MVC skeleton for quickly building PHP web applications.
Requirements
- PHP 7.4 or higher
- Composer
- Docker and Docker Compose, if you want to run the bundled local environment
Installation
Install PHP dependencies:
composer install
Composer installs dependencies into application/vendor.
Create your local environment file:
cp .env_example .env
The committed .env_example contains default values. The local .env file is
ignored by Git and can be adjusted per machine.
Run with Docker
Build and start the application:
docker compose up --build
Open the app in a browser:
http://localhost
The Docker setup uses:
- nginx on host port
80 - PHP-FPM
- MariaDB on host port
3307 - project root mounted to
/var/www/wps-micro-docker - nginx document root set to
/var/www/wps-micro-docker/public
If port 80 is already busy on your machine, change the nginx port mapping in
docker-compose.yaml, for example:
ports: - 8080:80
Then open:
http://localhost:8080
Inside Docker, the application connects to MariaDB through DB_HOST=mariadb.
If you run PHP directly on your machine and only use the MariaDB container,
change DB_HOST to 127.0.0.1 and keep DB_PORT=3307.
Run with a Local Web Server
Point your web server document root to the public directory and route all
missing files to public/index.php.
Example nginx rule:
location / { try_files $uri $uri/ /index.php?$query_string; }
The app expects public/index.php to be the front controller.
For a quick local check without nginx, you can use PHP's built-in server:
php -S localhost:8000 -t public public/index.php
Then open:
http://localhost:8000
Project Structure
public/index.php- front controllerpublic/css,public/js,public/img,public/fonts- public assetsapplication/bootstrap.php- application bootstrapapplication/Config/app.php- application configurationapplication/Database/schema.sql- local database bootstrap schema.env_example- environment configuration templateapplication/Core- framework core classesapplication/Controllers- application controllersapplication/Models- application modelsapplication/Views- Twig templatesapplication/Exceptions- custom exceptions
Request Lifecycle
The framework core follows a small request/response pipeline:
Request -> Router -> Dispatcher -> Controller -> Response
Requestwraps PHP globals and exposes method, path, headers, query data, and body data.Routermatches the request path to a controller action.Dispatchercreates the controller, executes the action, and normalizes the result.Controlleractions should return aResponse.Responsesends status, headers, and content to the client.
Routing
Explicit routes live in application/Routes/web.php and are registered by the
application kernel:
$router->get('/', [ControllerHome::class, 'actionIndex']); $router->get('/products/{id}', [ControllerProduct::class, 'actionShow']); $router->post('/cart/add', [ControllerCart::class, 'actionAdd']);
Route parameters are passed to action arguments with the same name:
public function actionShow(string $id): Response { // ... }
Forms can use _method to match PUT, PATCH, and DELETE routes.
Application Kernel
Kernel builds the framework infrastructure through a small shared-service
container. It creates the configured Twig environment, database connection,
Router, and Dispatcher; controller dependencies are resolved through
constructor injection.
Default application settings live in application/Config/app.php. Environment
overrides are loaded from .env before the kernel is created.
Model Layer
Models receive a configured PDO connection from the container and should focus
on application data access. Keep validation in validators, request handling in
controllers, and business workflows in services as the application grows.
Sessions
Controllers receive a shared Session service through the base controller. Use
$this->session->get(), $this->session->set(), and
$this->session->flash() for simple state such as carts, flash messages, and
authentication markers.
Migrations
Database migrations live in application/Database/migrations. Run pending
migrations with:
php application/console.php migrate
Roll back the last migration with:
php application/console.php migrate:rollback
Roll back multiple migrations with:
php application/console.php migrate:rollback --steps=2
The Docker database bootstrap schema also records the initial migration, so the
CLI migrator can be used safely after a fresh docker compose up.
webpagestudio/wps-micro 适用场景与选型建议
webpagestudio/wps-micro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 webpagestudio/wps-micro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webpagestudio/wps-micro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-31