phpdominicana/lightwave
Composer 安装命令:
composer require phpdominicana/lightwave
包简介
Simple php starter kit
README 文档
README
This is a simple PHP starter kit created by the PHP dominicana community. It is designed to help you get started with PHP development quickly. It includes a simple web server, a simple router It is designed to be simple and easy to use.
Installation
A few simple steps are needed to get this application up and running:
The next step assumes that composer is available in your PATH
composer create-project phpdominicana/lightwave [project-name]
cd [project-name]
Copy the .env.example file to .env and update the database connection settings.
cp .env.example .env
Usage with PHP native server
To start the PHP native server, run the following command:
sh server.sh
Add new routes
Routes are defined in the routes/web.php file. This file is loaded by the RouteServiceProvider.
To define routes, you can use the $router object, which is an instance of Phpdominicana\Lightwave\Router. It provides simple methods for common HTTP verbs:
<?php // routes/web.php use Phpdominicana\Lightwave\Controllers\HelloController; use Phpdominicana\Lightwave\Controllers\HomeController; use Phpdominicana\Lightwave\Router; /** @var Router $router */ // Example: GET route with a parameter $router->get('/hello/{name}', [HelloController::class, 'index']); // Example: GET route for the homepage $router->get('/', [HomeController::class, 'index']); // Example: POST route // $router->post('/users', [UserController::class, 'store']); // Example: PUT route // $router->put('/users/{id}', [UserController::class, 'update']); // Example: DELETE route // $router->delete('/users/{id}', [UserController::class, 'destroy']);
Controller Structure and Dependency Injection
Controller methods referenced in your routes can receive dependencies in two main ways:
-
Route Parameters: Any parameters defined in your route path (e.g.,
{name}in/hello/{name}) will be passed to your controller method as arguments with matching names.// In HelloController.php public static function index(string $name): Response { // $name will contain the value from the URL return new Response("Hello {$name}"); }
-
Service Container: If your controller method type-hints
Pimple\Psr11\Container(or its interfacePsr\Container\ContainerInterface), the application's service container will be injected. You can use this to resolve other services, like the view renderer.// In HomeController.php use Pimple\Psr11\Container; use Symfony\Component\HttpFoundation\Response; public static function index(Container $container): Response { $view = $container->get('view'); // Assuming 'view' service is registered return new Response($view->render('welcome.twig')); }
How to connect to a database using eloquent ORM
Install eloquent ORM
composer require illuminate/database
Add the EloquenServiceProvider to the src/Providers/AppServiceProvider class to the config/app.php file in the providers array.
'providers' => [ \Phpdominicana\Lightwave\Providers\AppServiceProvider::class, \Phpdominicana\Lightwave\Providers\TwigServiceProvider::class, \Phpdominicana\Lightwave\Providers\RouteServiceProvider::class, \Phpdominicana\Lightwave\Providers\EloquentServiceProvider::class ],
Then you can create you model and extend the Illuminate\Database\Eloquent\Model class.
<?php namespace Phpdominicana\Lightwave\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { protected $table = 'users'; protected $fillable = ['name', 'email', 'password']; }
phpdominicana/lightwave 适用场景与选型建议
phpdominicana/lightwave 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「starter kit」 「PHPDominicana」 「Lightwave」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpdominicana/lightwave 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpdominicana/lightwave 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpdominicana/lightwave 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Filament Starter.
A Software Development Kit for Silverstripe Search
Slim starter / Slim skeleton package to boost your development with Slim framework
Usefull userfuncs
A collection of necessary navigations
A collection of useful ViewHelpers
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-21