定制 jhonoryza/bandung-framework 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jhonoryza/bandung-framework

Composer 安装命令:

composer require jhonoryza/bandung-framework

包简介

small php framework

README 文档

README

Total Downloads Latest Stable Version License

Bandung Framework

small php framework

Framework Directory

  • app directory is playground for the framework
  • src directory is the core of the framework
  • public directory index.php will be called when serve web request
  • bandung file will be called when running console command
  • tests directory is where the test of the framework reside

Feature

  • route
  • request
  • response
  • console command

WIP

  • query builder
  • migration
  • queue
  • filesystem
  • mail
  • notification
  • event and listener

Getting Started

create empty project

mkdir myapp
cd myapp
composer init

installation

composer require jhonoryza/bandung-framework
cp vendor/jhonoryza/bandung-framework/bandung .
php bandung install

after installation completed there will be several files in your project

  1. app/ directory, use this folder to put class controller and command, the framework will scan this folder
  2. public/index.php this is the entry point for your web application
  3. bandung this is the entry point for your console command

create a simple endpoint

in app directory you can create a class lets say HomeController and

let's create a route /, /posts and /posts/{id}

    #[Get(uri: '/')]
    public function index(): ResponseInterface
    {
        return Response::make(HttpHeader::HTTP_200, 'Hello world!');
    }

    #[Get(uri: '/posts')]
    public function posts(): ResponseInterface
    {
        return JsonResponse::make(HttpHeader::HTTP_200, [
            'message' => 'ok'
        ]);
    }

    #[Get(uri: '/posts/{id}')]
    public function postDetail(string $id): ResponseInterface
    {
        return JsonResponse::make(HttpHeader::HTTP_200, [
            'message' => 'ok',
            'id' => $id
        ]);
    }

the Attributes #[Get('/')] will mark this function as a route /

let's run php bandung serve and open http://127.0.0.1:8000

get environment variables

$appName = getenv('APP_NAME');
echo $appName;

console command

you can run like this php bandung this will print all available commands

let's create a custom command

in app directory you can create a class lets say CommandClass and

let's create a function testWarning

    #[Command('test:warning')]
    public function testWarning(): void
    {
        warning('testing warning ok');
    }

the Attributes #[Command('test:warning')] will mark this function as command with name test:warning

you can call it from terminal : php bandung test:warning

Test

./vendor/bin/phpunit

Security

If you've found a bug regarding security please mail jardik.oryza@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-16