承接 genesis/micro-framework 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

genesis/micro-framework

Composer 安装命令:

composer require genesis/micro-framework

包简介

Simple classes tied with a convention.

README 文档

README

Bunch of classes with a bit of convention to get your started.

Setup

To get boiler plate code for a quick start, run the following commands (bash/cli acquainted users):

composer require genesis/micro-framework
make -f vendor/genesis/micro-framework/Makefile build

At the end of the output you'll receive a snippet for the composer.json file, add and now start local server:

make serve

open localhost:8000 in your browser and you should see hello world!.

If the above steps do not work, run make -f vendor/genesis/micro-framework/Makefile cleanup and proceed step by step:

Place the following code in your index file. Assuming that:

  • the index file is in the public folder.
  • you have an autoloading rule in composer.json file that points the namespace App\Controller to your controllers folder.
<?php

use Genesis\Microframework\Service\Config;
use Genesis\Microframework\Service\Router;
use Genesis\Microframework\Service\Request;
use App\Controller;

require __DIR__ . '/../vendor/autoload.php';

$router = new Router($_GET, $_SERVER);
$router->registerRoutes(
    [
        '/' => Controller\Index::class,
    ]
);

Config::set('view_path', __DIR__ . '/../src/View/');
$router->dispatchRequest(new Request());

The dispatcher will call upon the index() method in each controller only.

Database

To add database support, add config for database like so in the above file before the dispatchRequest() call:

Config::set('db_params', [
    'dbengine' => 'mysql',
    'host' => 'localhost',
    'port' => 3306,
    'dbname' => 'myDB',
    'username' => 'root',
    'password' => 'password'
]);

And call upon the getMapperService() method to persist your models. For more information follow guide here https://github.com/forceedge01/genesis-persistence.

View

Call a view in your controller like so:

# src/Controller/Index
<?php

namespace App\Controller;

use Genesis\MicroFramework\Controller\BaseController;

/**
 * Index class.
 */
class Index extends BaseController
{
    public function index()
    {
        echo $this->render('index.php', [
            'name' => 'Abdul'
        ]);
    }
}

Expect to have a view file src/View/index.php which renders the variable name. There is no engine supplied but can be added.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-15