devamiri / devbolt
DevBolt 是一个用于简化 Web 应用程序开发的 PHP 框架。它为您的应用程序提供了一个强大的结构,并提供了一系列工具,使常见的 Web 开发任务更加容易。
1.0.0
2024-07-21 15:51 UTC
Requires
- ext-openssl: *
- ext-pdo: *
- eftec/bladeone: ^4.13
- fakerphp/faker: ^1.23
- filp/whoops: ^2.15
- illuminate/database: 11.0
- monolog/monolog: ^3.6
- swiftmailer/swiftmailer: ^6.3
- symfony/http-foundation: ^7.0
- symfony/translation: ^7.0
- vlucas/phpdotenv: ^5.6
This package is auto-updated.
Last update: 2024-10-01 11:17:05 UTC
README
介绍
DevBolt 是一个用于简化 Web 应用程序开发的 PHP 框架。它为您的应用程序提供了一个强大的结构,并提供了一系列工具,使常见的 Web 开发任务更加容易。
目录
安装
要安装 DevBolt,请克隆仓库并使用 Composer 安装依赖项
composer create-project devamiri/devbolt
或
git clone https://github.com/DevAmiri-iran/DevBolt.git
和
cd DevBolt
composer install
使用
启动服务器
Running the project with a browser
功能
- Blade 模板引擎
- 数据库迁移
- 内部 API 管理
依赖项
- PHP 8.2 或更高版本
- Composer
- MySQL
配置
将 .env.example 复制到 .env 并设置环境变量
cp .env.example .env
示例
路由
以下是一个简单的路由定义示例
Route::api('/', 'index'); Route::view('/', 'index');
或
Route::post('/', function (){ return 'hello world'; }); Route::get('/', function (){ return 'hello world'; });
数据库
要使用数据库
System::useDatabase();
在 app/bootstrap.php 文件中添加
迁移
以下是一个简单的迁移定义示例
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Capsule\Manager as Capsule; return new class { public string $table = 'users'; /** * Run the migrations. * * @return void */ public function up(): void { Capsule::Schema()->create($this->table, function (Blueprint $table) { $table->id(); $table->string('username', 50); $table->string('password', 50); $table->string('email', 100); $table->string('phone_number', 20)->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down(): void { Capsule::Schema()->dropIfExists($this->table); } };
模型
以下是一个简单的模型定义示例
namespace App\Database\Models; use Illuminate\Database\Eloquent\Model; class Users extends Model { protected $table = 'users'; protected $fillable = ['username', 'password', 'email', 'phone_number']; }
中间件
以下是一个简单的中间件定义示例
namespace App\Middleware; class Test { public function handle($value=null) { if ($value == 'start') { dd('The project was started'); } } }
APIManager
以下是一个简单的 API 处理器定义示例
use App\Support\APIManager; $API = new APIManager($request = APIManager::input(), true, true); $API->validateParameters('password'); $API->handle(function () use ($request){ if ($request['password'] == '123') APIManager::respond(true, 'Your password is correct'); else APIManager::respond(false, 'Your password is not correct'); });
贡献者
许可
本项目采用 MIT 许可证。有关详细信息,请参阅 LICENSE 文件。
Feel free to modify this template based on additional details or specific requirements of your project.