Download the PHP package ctfang/universe without Composer

On this page you can find all versions of the php package ctfang/universe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package universe

这是一个基于swoole扩展的php框架,调试模式下代码跟普通php-fpm模式一样,是实时生效的;框架部分大量参考了phalcon和laravel代码的实现,例如框架骨架使用了DI服务,所有框架先注册进入DI树,注册完后才使用,这样可以更好的扩展框架功能,哪怕是覆盖框架核心服务都行。因为universe是常住内存运行的,所以DI服务都是一次注册多次使用。

Build Status License

About Universe

2.0.* 版本已经抛弃fpm模式运行,调试模式可以自动reload,实现代码实时生效

Note: Universe的目标是所有注册进di的服务都由第三方开发,让更多的人参与开发

已经实现的功能列表

安装使用 composer安装 ~~~~ composer create-project ctfang/universe ~~~~ git安装 ~~~~ git clone https://github.com/ctfang/Universe.git cd Universe composer install ~~~~ 运行,单独运行php server有帮助命令,例如http使用: ~~~~php // 守护模式,调试下支持代码更改实时生效 php server http:start // 非守护模式 php server http:start --daemonize=0 // 重启服务 php server http:reload php server http:stop ~~~~ 启动时,会输出域名端口基本信息 ~~~~ ----------------- ------------------------------------------------------- 配置key 值 ----------------- ------------------------------------------------------- 监听域名 0.0.0.0 监听端口 8081 log_file /data/webpages/swoole-demo/storage/swoole.log pid_file /data/webpages/swoole-demo/bootstrap/cache/server.pid log_level 5 worker_num 4 task_worker_num 0 守护模式 是 ----------------- ------------------------------------------------------- ~~~~ 如果需要访问静态资源,html、css、js等;可以配置nginx服务器,配置模板 bootstrap\swoole.app.conf ~~~~ server { listen 80; server_name demo.app; root /data/webpages/swoole-demo/public; index index.html; location / { try_files $uri @swoole; } location @swoole { proxy_http_version 1.1; proxy_set_header Connection "keep-alive"; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://php:8081; } } ~~~~
代码即时生效 借助中间件,在所有业务处理完后,向server发起reload,新的请求就运行新的代码。 注入di的服务不会立即更新
配置载入 所有的配置都在config目录下,默认加载配置文件 ~~~~ universe/config/app.php ~~~~
控制器 一个基础的控制器定义 ~~~~php namespace App\Http\Controllers; class IndexController extends Controller { public function getString() { return '输出字符串;获取请求参数:'.$this->request->get('id','int',0); } public function getJson() { return [ 'time'=>time(), 'string'=>'响应json格式,自动加Json Header', ]; } } ~~~~ 访问上面示范两个函数需要添加路由,路由文件在 /config/route.php ~~~~php Route::get('/string', 'IndexController@getString'); Route::get('/index/json', 'IndexController@getJson'); ~~~~ 路由器访问 http://test.test/index/json 就可以进入 getJson
路由 所有接口都必须在路由文件/config/route.php注册 ~~~~php Route::get('/string', 'IndexController@getString'); Route::get('/index/json', 'IndexController@getJson'); // 注册一个分组,分组内的路由都会添加 /test 前缀 // middleware参数是所有请求都会进入login中间件,例如实现/test开头的路由都必须登录后才能访问 Route::group(['prefix' => '/test', 'middleware' => 'login'],function () { Route::get('/one', 'IndexController@one'); Route::get('/two', 'IndexController@two'); }); ~~~~
中间件 中间的使用基本和laravel一模一样,中间件在控制器前还是后执行,是有中间件本身决定的,所有中间件都在目录/app/http/middleware下 ~~~~php namespace App\Http\Middleware; use Universe\Support\Middleware; use Universe\Servers\RequestServer; class AuthMiddleware extends Middleware { /** * @param RequestServer $request * @param $next */ public function handle(RequestServer $request, $next) { // 这里的代码在控制器前运行 $response = $next($request); // 这里的代码在控制器后运行 return $response; } } ~~~~ 完全由 $next($request) 决定中间件的运行前后。 当然中间一般都用来权限校验或者重定向等。 ~~~~php class AuthMiddleware extends Middleware { /** * @param RequestServer $request * @param $next */ public function handle(RequestServer $request, $next) { if( !is_login() ){ // 没有登录重定向到登陆页面 $request->setUri('/login'); // 需要重新向新地址,返回 新地址 对象即可 return $request; } if( !$request->get('token') ){ /** * 需要验证token的接口,没有参数 * 返回数组,获取字符串,就可以停止执行 */ return [ 'error'=>'403', 'error_msg'=>'没有权限', ]; } // 可以进入控制器 return $next($request); } } ~~~~
异常服务 /app/Exceptions/Kernel.php 注册异常需要经过的handler ~~~~php class Kernel extends ExceptionKernel { /** * 注册异常处理 * * @return mixed * @author 明月有色 <[email protected]> */ public function register() { if( is_debug() ){ // 如果调试,把错误展示出来 $this->server->pushHandler(new PrettyPageHandler()); } // 所有错误日记记录 $this->server->pushHandler(new LoggerHandler()); // 404 优先处理 $this->server->pushHandler(new NotFoundHandler()); } } ~~~~ 上面注册了3个handler - 把所有错误写入日记 - 把错误显示出来 - 404展示一个简单页面
数据模型 ~~~~php dump(DB::table('test')->find(1)); User::find(1);l ~~~~ 使用上完全跟laravel一样,因为集成的是相同的composer包,如果需要用其他的orm,重新注册DI即可
事件系统 ~~~~php App::get('events') ~~~~
数据迁移 输入命令查看帮助,集成phinx ~~~~php php moon ~~~~

连接池,如果需要orm默认使用连接池执行,可以在database注入时,传入新的Connection 默认Connection在 /illuminate/database/Connection.php 新Connection继承/illuminate/database/Connection.php,并且参考651行runQueryCallback函数

如何加入开发组

开发组


All versions of universe with dependencies

PHP Build Version
Package Version
Requires vlucas/phpdotenv Version ^2.4
symfony/var-dumper Version ^3.3
symfony/console Version ~3
nikic/fast-route Version ^1.2
monolog/monolog Version ~1.12
filp/whoops Version ^2.1.4
illuminate/database Version ~5.6
illuminate/events Version ~5.6
symfony/finder Version ~4.0
robmorgan/phinx Version ^0.9.2
symfony/cache Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ctfang/universe contains the following files

Loading the files please wait ....