arvici / framework
Arvici 框架
2.0.0-rc.2
2018-03-27 08:56 UTC
Requires
- php: >=7.0.0
- ext-mbstring: *
- doctrine/annotations: 1.4.0
- doctrine/dbal: 2.5.13
- doctrine/migrations: 1.5.0
- doctrine/orm: 2.5.14
- filp/whoops: 2.1.14
- indigophp/hash-compat: 1.1.0
- maximebf/debugbar: 1.13.1
- monolog/monolog: 1.23.0
- mustache/mustache: 2.11.1
- psr/http-message: 1.0.1
- psr/log: 1.0.2
- swiftmailer/swiftmailer: 6.0.2
- symfony/console: 3.3.16
- symfony/form: 3.3.16
- symfony/http-foundation: 3.3.16
- symfony/monolog-bridge: 3.3.16
- symfony/psr-http-message-bridge: 1.0.2
- symfony/security: 3.3.16
- symfony/validator: 3.3.16
- symfony/var-dumper: 3.3.16
- tedivm/stash: 0.14.2
- tomvlk/sweet-orm: 2.0.0-rc.1
- twig/twig: 2.4.7
Requires (Dev)
- codacy/coverage: 1.4.0
- phpunit/php-code-coverage: 5.3.0
- phpunit/phpunit: ~6.5.7
- satooshi/php-coveralls: 1.1.0
This package is not auto-updated.
Last update: 2024-09-14 18:20:40 UTC
README
Arvici 框架
简介
此包包含 Arvici 框架的核心功能。目前处于开发中!
入门
仅适用于专家使用此包,请点击以下链接获取如何开始使用框架的说明。 入门,使用 composer create-project
组件
路由器
您可以在 Router.php 配置中定义您的路由。使用 Router::define 方法定义您的路由。
示例
Router::define(function(Router $router) { $router->get('/', '\App\Controller\Welcome::index'); $router->get('/session', '\App\Controller\Welcome::session'); $router->get('/json', '\App\Controller\Welcome::json'); $router->get('/exception', '\App\Controller\Welcome::exception'); });
数据库
您的数据库配置位于 Database.php。
示例
Configuration::define('database', function() { return [ /** * The default fetch type to use. */ 'fetchType' => \Arvici\Heart\Database\Database::FETCH_ASSOC, /** * Database Connection names and configuration values. * * 'default' is used when no connection name is provided, or using SweetORM. */ 'connections' => [ 'default' => [ 'driver' => 'MySQL', 'host' => 'localhost', 'username' => 'root', 'password' => '', 'port' => 3306, 'database' => 'arvici_test' ], ] ]; });
模型/ORM
使用 ORM 时,请查阅单独的文档: https://github.com/tomvlk/sweet-orm#defining-entities
缓存
要使用缓存系统,您必须定义缓存配置或默认使用文件系统。
配置文件 Cache.php
Configure::define('cache', function () { return [ /** * Enable cache. */ 'enabled' => true, /** * Set to true to enable cache even in non-production mode. */ 'forceEnabled' => true, /** * Cache Pool Configuration. */ 'pools' => [ 'default' => [ 'driver' => '\Stash\Driver\FileSystem', 'options' => [ 'path' => BASEPATH . 'cache' . DS, ] ], ], ]; });
使用缓存池
要检索池(您可以在其中保存和获取项目),您必须使用管理器。
$manager = \Arvici\Component\Cache::getInstance();
在下一步中,您需要获取池。池在您的配置文件中配置。
$pool = $manager->getPool(); // pool name = 'default' // or with a pool name: $pool = $manager->getPool('redis-cache'); // pool name = 'redis-cache'
要检索、保存或使用项目,您首先需要获取上下文。使用 Item 实例可以读取和操作内容。
使用示例
$item = $pool->get('test/cachingkey'); $item->set($data); $expiration = new DateTime('2020-01-21'); $item->expiresAfter($expiration); $item->save(); $data = $item->get(); $item->isMiss(); // bool
更多信息
使用的缓存库是 Stash。有关使用池的更多信息,请参阅: http://www.stashphp.com/Basics.html
许可证
MIT 许可证,请参阅 LICENSE 文件。