logikostech/core 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

logikostech/core

Composer 安装命令:

composer require logikostech/core

包简介

LT Project Core

README 文档

README

Travis CI Software License

Core for LT projects.

Logikos\Application\Bootstrap

Basic usage

  // public/index.php

  $basedir = realpath(__DIR__.'/..');
  $appdir  = $basedir.'/app';
  
  /**
   * Composer
   */
  $composer = $basedir . '/vendor/autoload.php';
  if (file_exists($composer))
    include_once $composer;


  $boot = new Bootstrap([
      'basedir' => $basedir,
      'appdir'  => $appdir,
      'confdir' => $appdir.'/config'
  ]);

  /**
   * get loaded config from Bootstrap, which will auto merge $confdir."/".getenv('APP_ENV').".php"
   */
  $config = Bootstrap::getConfig();

  /**
   * Include services
   */
  $di = require APP_PATH . '/config/services.php';

  echo $boot->getContent();

Logikos\Application\Bootstrap\Modules

If you pass module configuration information to Bootstrap(), either the module definitions or the defaultModule then bootstrap will automaticly try to initialize the modules Bootstrap::initModules()

Of course you can always initModules manualy yourself:

  $appdir = realpath(__DIR__.'/../app');
  $boot = new Bootstrap($options);
  $boot->initModules(
    [
      'frontend' => [
        'className' => 'Frontend\Module',
        'path'      => $appdir.'/modules/frontend/Module.php'
      ],
      'backend' => [
        'className' => 'Backend\Module',
        'path'      => $appdir.'/modules/backend/Module.php'
      ]
    ],
    [
      'defaultModule' => 'frontend',
      'modulesDir'    => $appdir.'/modules'
    ]
  );
  echo $boot->getContent();

Note that by specifying modulesDir we really would not have needed to define the modules as the class automaticly finds and registers all modules within the modulesDir. Also the default modulesDir is APP_DIR.'/modules' and the default defaultModule is 'frontend' so really $boot->initModules() would work all by itself with no options if the defaults work for your application.

Module Routeing

By default the Modules class will automaticly register your modles with the router. It uses /controller/action/params for the default module and /modulename/controller/action/params for all non-default modules. You can override this per module however within your ModuleDefinition class

class Module implements ModuleDefinitionInterface {
  public static function defineRoutes(DiInterface $di) {
    /* @var $router \Phalcon\Mvc\Router */
    $router  = $di->get('router');
    $default = $router->getDefaults()['module'];

    $router->add("/customroute/foo/:params", array(
        'module' => 'somemodule,
        'controller' => 'index',
        'action' => 'foo',
        'params' => 1
    ))->setName('somemodule_foo');
  }
  

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-29