承接 atlantic8-web/slim-magic 相关项目开发

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

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

atlantic8-web/slim-magic

Composer 安装命令:

composer require atlantic8-web/slim-magic

包简介

An auto router, auto discovery class mapper/loader for Slim Framework 3. Keeping your Slim bootstrapping clean no matter how many routes, dependencies and middleware you have.

README 文档

README

A bootstrapper/classmapper/loader for Slim Framework 3x. Keeping your Slim bootstrapping clean no matter how many routes, dependencies and middleware you have, allowing you to build really large applications in a structured manner.

Installation

It's recommended that you use Composer to install SlimMagic.

$ composer require atlantic8-web/slim-magic "^1.0"
// or add to your existing composer.json file

This will install SlimMagic and all required dependencies. SlimMagic requires PHP 5.5.0 or newer.

Configuration

'slim_magic_settings' => [
        'debug'=>false,
        'routes' => [
            //Home
            '/' => [
                'methods' => ['GET'], //Can be an array of methods, or ommit for default GET
                'classmap' => 'app\Home:index', //String resolver app
                'middleware' => [], //Middleware to load for this app
                'arguments' => [],//Arguments to pass to this app
                'name' => 'home' //App name, also used to generate URL's $slim->setName(...)
            ],
            '/admin/dashboard' => [
                'methods' => ['GET'],
                'classmap' => 'app\Admin:dashboard',
                'middleware' => ['AuthValidation', 'GrapPreload'],
                'arguments' => ['isAdmin'],
                'name' => 'admin_dashboard'
            ]
        ],
        //This will be applied to all routes/apps
        'all' => [
            'middleware' => ['Test', 'Session'],//See Slim docs for importance of order               
            'service' => ['SessionHelper', 'Twig', 'notFoundHandler'] //Service dependencies
        ]
    ]
        

Directory structure

In order to keep things clean we can use folders and service bootstrapper classes - See code example

MyNewApp
    -app
    -config
        -slim.php
    -service
        -Dependency
        -Middleware
    -view
    -model
-.htaccess
-index.php

Usage

Create a Slim config.php and add SlimMagic route setup and configuration - See code example

Create an index.php file with the following contents:

<?php

require 'vendor/autoload.php';

$container = new \Slim\Container(require 'config/slim.php');

$service = new \SlimMagic\ServiceContainer(new \Slim\App($container), $container->slim_magic_settings);
new \SlimMagic\Mapper($service);

$service->getSlim()->run();

See code example, configuration and architecture (CLI is no longer supported, instead handle CLI via your bootstrap) Example

License

The SlimMagic is licensed under the MIT license. See License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-18