Skip to content

Commit 549b56b

Browse files
committed
Merge branch 'dev'
* dev: dev-master alias callAction branch alias phpunit-speedtrap in travis-ci v2.0.0
2 parents 09e137d + 8b17918 commit 549b56b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+679
-4088
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
coverage_clover: build/logs/clover.xml
3+
json_path: build/logs/coveralls-upload.json

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
dist: trusty
2+
sudo: false
3+
4+
language: php
5+
6+
env:
7+
global:
8+
- COMPOSER_ARGS="--ansi --prefer-dist --no-interaction --no-suggest --no-progress --optimize-autoloader"
9+
- DEPS="phpunit/phpunit squizlabs/php_codesniffer php-coveralls/php-coveralls johnkary/phpunit-speedtrap"
10+
11+
git:
12+
depth: 3
13+
14+
cache:
15+
directories:
16+
- $HOME/.composer/cache
17+
18+
matrix:
19+
fast_finish: true
20+
allow_failures:
21+
- php: hhvm
22+
- php: nightly
23+
include:
24+
- php: 7.0
25+
- php: 7.1
26+
env: ANALYSIS="true"
27+
- php: 7.2
28+
- php: hhvm
29+
- php: nightly
30+
31+
before_script:
32+
- composer require --dev $COMPOSER_ARGS $DEPS
33+
34+
script:
35+
- php vendor/bin/phpunit
36+
- if [[ "$ANALYSIS" == "true" ]]; then php vendor/bin/phpcs ; fi
37+
38+
after_script:
39+
- if [[ "$ANALYSIS" == "true" && -f ./build/logs/clover.xml ]]; then php vendor/bin/php-coveralls -v; fi

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Soli PHP Framework
22
--------------------
33

4-
Soli 是一个轻量级的 PHP 框架,参考了 [Phalcon]
5-
框架的设计,意在松耦合、可扩展、简洁易用。
4+
Soli 是一个轻量级的 PHP 框架,框架的设计,意在松耦合、可扩展、简洁易用。
65

76
## 提供的功能
87

@@ -20,7 +19,6 @@ MVC、[依赖注入]、[事件管理]、[闪存消息]、[模版引擎]([Twig]
2019

2120
[MIT License]
2221

23-
[Phalcon]: https://phalconphp.com/
2422
[Twig]: http://twig.sensiolabs.org/
2523
[Smarty]: http://www.smarty.net/
2624
[依赖注入]: http://api.soliphp.com/Soli/Di.html

composer.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@
1818
"require": {
1919
"php": ">=7.0",
2020
"ext-mbstring": "*",
21-
"psr/container": "^1.0",
22-
"nikic/fast-route": "^1.3"
23-
},
24-
"replace": {
25-
"soliphp/di": "*",
26-
"soliphp/events": "*"
27-
},
28-
"suggest": {
29-
"smarty/smarty": "Smarty templating system",
30-
"twig/twig": "Twig templating system"
21+
"soliphp/di": "^2.0",
22+
"soliphp/events": "^1.3"
3123
},
3224
"provide": {
3325
"psr/container-implementation": "^1.0",
@@ -43,5 +35,16 @@
4335
"Soli\\Tests\\": "tests/"
4436
}
4537
},
38+
"repositories": {
39+
"packagist": {
40+
"type": "composer",
41+
"url": "https://packagist.laravel-china.org"
42+
}
43+
},
44+
"extra": {
45+
"branch-alias": {
46+
"dev-master": "2.0.x-dev"
47+
}
48+
},
4649
"minimum-stability": "dev"
4750
}

src/Soli/App.php

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* @author ueaner <[email protected]>
4+
*/
5+
namespace Soli;
6+
7+
/**
8+
* 应用
9+
*
10+
* @property \Soli\RouterInterface $router
11+
* @property \Soli\DispatcherInterface $dispatcher
12+
*/
13+
class App extends Component
14+
{
15+
const VERSION = '2.0.0-dev';
16+
17+
const ON_BOOT = 'app.boot';
18+
const ON_FINISH = 'app.finish';
19+
const ON_TERMINATE = 'app.terminate';
20+
21+
/**
22+
* 默认核心服务
23+
*/
24+
protected $coreServices = [
25+
//'router' => \Soli\RouterInterface::class,
26+
'dispatcher' => \Soli\Dispatcher::class,
27+
'events' => \Soli\Events\EventManager::class,
28+
];
29+
30+
/**
31+
* 应用初始化
32+
*/
33+
public function __construct()
34+
{
35+
$this->registerCoreServices();
36+
// $this->registerAppServices();
37+
}
38+
39+
protected function registerCoreServices()
40+
{
41+
$container = $this->getContainer();
42+
43+
foreach ($this->coreServices as $name => $service) {
44+
// 允许自定义同名的 Service 覆盖默认的 Service
45+
if (!$container->has($name)) {
46+
$container->set($name, $service);
47+
}
48+
}
49+
}
50+
51+
/**
52+
* 应用程序启动方法
53+
*/
54+
public function handle($argv = null)
55+
{
56+
$this->trigger(static::ON_BOOT);
57+
58+
$router = $this->router;
59+
$dispatcher = $this->dispatcher;
60+
61+
$router->dispatch($argv);
62+
63+
// 调度器预处理:设置命名空间、控制器、方法及参数
64+
if ($router->getNamespaceName()) {
65+
$dispatcher->setNamespaceName($router->getNamespaceName());
66+
}
67+
if ($router->getHandlerName()) {
68+
$dispatcher->setHandlerName($router->getHandlerName());
69+
}
70+
if ($router->getActionName()) {
71+
$dispatcher->setActionName($router->getActionName());
72+
}
73+
if ($router->getParams()) {
74+
$dispatcher->setParams($router->getParams());
75+
}
76+
77+
// 执行调度
78+
$returnedResponse = $dispatcher->dispatch();
79+
80+
$this->trigger(static::ON_FINISH, $returnedResponse);
81+
82+
return $returnedResponse;
83+
}
84+
85+
public function terminate()
86+
{
87+
$this->trigger(static::ON_TERMINATE);
88+
}
89+
}

src/Soli/Application.php

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)