v3knet/module

此包已被废弃,不再维护。未建议替代包。
关于此包最新版本(0.2.0)的许可证信息不可用。

维护者

详细信息

github.com/v3knet/module

源代码

安装: 182

依赖项: 3

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

类型:项目

0.2.0 2015-09-27 22:52 UTC

This package is not auto-updated.

Last update: 2021-08-07 01:51:29 UTC


README

内置功能

  1. Twig/Bootstrap/Google analytics/…
  • Doctrine Cache, DBAL, ORM
  • BernardPHP 消息队列
  • SF2 Console(将你的命令作为服务,命名为 anything.command.the_name,然后运行 php cli.php,你会看到你的命令自动注册)
  • 模块系统,以 ./modules/system 为例。
  • Swagger UI

用法

在你的项目的 composer.json 文件中需要 atphp/atsilex

{
  "name": "v3knet/website",
  "require": {
    "atphp/atsilex": "^0.1.0"
  },
  "scripts": {
    "post-install-cmd": [
      "atsilex\\module\\system\\commands\\InstallerScript::execute"
    ]
  },
  "extra": {
    "atsilex": {
      "%site_name%": "My Project",
      "%site_version%": "1.0-dev",
      "%site_url%": "http://www.vendor-name.com/",
      "%site_frontpage%": "hello",
      "%site_ga_code%": "UA-1234567-890",
      "%vendor_name%": "Vendor Name"
    }
  }
}

在 composer 安装过程中,atsilex 将为你的应用程序设置默认结构

files/                   # Directory to store temporary files (cache, compiled templates, …)
config.default.php       # (*) Default 
config.php               # The file that return configuration for application.
public/                  # Document root
      /index.php         # (*) Front controller
      /assets/modules/*  # Symlinks for modules's assets
                         # Don't edit (*), they will be overwritten in next composer install.

编写自定义模块

模块基本上是一个扩展 atsilex\module\Module 的类。每个模块都可以

  1. 定义自定义服务

定义模块很简单,你还需要通知应用程序你的模块——编辑 config.php,在其中包含你的模块

return [
    // …
    'modules' => [
        'my_module' => 'MyModule',
        'system'    => 'atsilex\module\system\SystemModule', # Can't disable
    ],
    // …
];

配置数据库连接

应用程序的默认数据库是一个 SQLite 文件,当我们运行 php public/index.php orm:schema-tool:create 命令时,它将自动创建在 files/app.db

要更改默认的数据库连接配置,在 config.php 中添加类似以下代码

# SQlite
# $db_options = ['driver' => 'pdo_sqlite',  'path' => '/alternative/path/to/app.db'];

# MySQL
$db_options = [
    'driver'    => 'pdo_mysql',
    'host'      => 'mysql_write.someplace.tld',
    'dbname'    => 'my_database',
    'user'      => 'my_username',
    'password'  => 'my_password',
    'charset'   => 'utf8mb4',
];

return [
 // …
 'db.options' => $db_options,
 // …
];