Commit da733a49 by 杨树贤

Initial commit

parents
Showing with 4166 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

APP_ENV=local
APP_DEBUG=false
APP_KEY=
APP_TIMEZONE=PRC
//系统编码,用于生成错误码
SYSTEM_CODE=11
ELK_NAME=lc_server_order
//系统名称,用于告警识别
SYSTEM_NAME=客服系统服务(开发环境)
at=13510507993
//laravels监听IP和端口
LARAVELS_LISTEN_IP=0.0.0.0
LARAVELS_LISTEN_PORT=61011
//是否开启定时任务
timer=true
DB_HOST_W=192.168.2.239
DB_HOST_R=192.168.2.239
DB_DATABASE=lc_order
DB_USERNAME=root
DB_PASSWORD=root
DB_PORT=3306
DB_PREFIX=ic_
//CMS的数据库配置
DB_CMS_HOST_W=192.168.2.232
DB_CMS_HOST_R=192.168.2.232
DB_CMS_DATABASE=ichuntcms
DB_CMS_USERNAME=ichuntcms
DB_CMS_PASSWORD=ichuntcms#zsyM
DB_CMS_PORT=3306
DB_CMS_PREFIX=
REDIS_HOST=192.168.1.235
REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379
REDIS_READ_HOST=192.168.1.235
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
//RBMQ配置
QUEUE_DRIVER=rabbitmq
RABBITMQ_HOST=
RABBITMQ_PORT=
RABBITMQ_VHOST=
RABBITMQ_LOGIN=
RABBITMQ_PASSWORD=
RABBITMQ_EXCHANGE=
CACHE_DRIVER=file
QUEUE_DRIVER=sync
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
QUEUE_DRIVER=sync
/.idea
Homestead.json
Homestead.yaml
[submodule "common"]
path = common
url = ssh://git@119.23.72.7:22611/yyc/Common.git
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
//
}
}
<?php
namespace App\Events;
use Illuminate\Queue\SerializesModels;
abstract class Event
{
use SerializesModels;
}
<?php
namespace App\Events;
class ExampleEvent extends Event
{
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
}
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response;
use PDOException;
use Predis\Connection\ConnectionException;
use Symfony\Component\Debug\Exception\FatalThrowableError;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
$report = [
'code' => $this->getCode($e),
'message' => toUtf8($e->getMessage()),
'file' => $e->getFile(),
'line' => $e->getLine(),
'request' => json_encode(Request::input()),
];
\LogReport::write(\LogReport::anlyError($report));
if (!env('APP_DEBUG')) {
SendAlarm($e,config('website.SystemName'));
}
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
$code = $this->getCode($e);
$msg = '系统错误,请联系客服处理';
$data = '';
if (env('APP_DEBUG')) {
$log = [toUtf8($e->getMessage()), $e->getFile(), $e->getLine()];
$data = implode(" ", $log);
}
return Response()->json(['errcode' => $code, 'errmsg' => $msg.' #'.getUnique(true), 'data' => $data]);
// return parent::render($request, $e);
}
private function getCode($e)
{
$systemcode = config('website.SystemCode');
if ($e instanceof PDOException) {
$code = errCode(001, 9, $systemcode);
} elseif ($e instanceof ConnectionException) {
$code = errCode(002, 9, $systemcode);
} elseif ($e instanceof FatalThrowableError) {
$code = errCode(003, 9, $systemcode);
} elseif (strpos($e->getFile(), 'RoutesRequests') !== false) {
$code = 404;
} else {
$code = $e->getCode() ? $e->getCode() : '';
}
return $code;
}
}
<?php
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
//错误码列表
//添加失败
const ADD_FAIL = 001;
//更新失败
const UPDATE_FAIL = 002;
//删除失败
const DELETE_FAIL = 003;
public function Export( $Errcode = 0 , $level = 1 , $dataArr = '') {
//生成错误码
$Errcode = $this->Errcode($Errcode , $level);
//获取错误描述
$ErrMsg = config('errmsg.cn.'.$Errcode);
//上报错误
$data=['errcode'=>$Errcode, 'errmsg'=>$ErrMsg];
if(($data['errcode'] < 10000 || $data['errcode'] >= 50000) && $data['errcode'] !==0 )//非正常返回码,上报
ErrorLog($Errcode,$ErrMsg);
if(!empty($dataArr) && is_array($dataArr))
foreach ($dataArr as $k=>$v) $data[$k]=$v;
else
$data['data'] = $dataArr;
return json_encode($data);
}
/**
* @param int $code 错误码
* @param int $level 错误级别 1普通错误 5需关注错误 9致命错误,急需解决
* @return int
*/
protected function Errcode( $code = 0,$level=1){
if($code === 0) return 0;
$SystemCode=config('website.SystemCode');
return errCode($code,$level,$SystemCode);
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Filters\CustomerFilter;
use App\Http\Filters\QueryFilter;
use App\Model\CustomerModel;
use Illuminate\Http\Request;
class CustomersController extends Controller
{
public function index(Request $request, CustomerModel $customerModel, CustomerFilter $filter)
{
$list = $customerModel->customerList($filter);
return $this->Export(0, 'ok', $list);
}
public function info(Request $request, CustomerModel $customerModel)
{
$userId = $request->get('user_id');
$info = $customerModel->getCustomer($userId);
return $this->Export(0, 'ok', ['data' => $info]);
}
public function changeStatus(Request $request, CustomerModel $customerModel)
{
$userId = $request->get('user_id');
$status = $request->get('status');
$result = $customerModel->changeStatus($userId, $status);
if ($result) {
return $this->Export(0);
}
return $this->Export(self::UPDATE_FAIL, 5);
}
}
\ No newline at end of file
<?php
namespace App\Http\Filters;
use Illuminate\Support\Facades\Log;
class CustomerFilter extends QueryFilter
{
public function company_name($companyName)
{
return $this->builder->where('company_name', 'like', "%$companyName%");
}
public function auth_type($authType = 0)
{
return $this->builder->where('auth_type', $authType);
}
public function add_time($addTime)
{
$addTime = explode('~', urldecode($addTime));
foreach ($addTime as $key => $value) {
$addTime[$key] = strtotime($value);
}
return $this->builder->whereBetween('add_time', $addTime);
}
public function reg_time($regTime)
{
$regTime = explode('~', urldecode($regTime));
foreach ($regTime as $key => $value) {
$regTime[$key] = strtotime($value);
}
return $this->builder->whereBetween('reg_time', $regTime);
}
public function mobile($mobile)
{
return $this->builder->where('mobile', 'like', "%$mobile%");
}
public function source($source)
{
return $this->builder->where('source', $source);
}
public function last_visit_time($lastVisitTime = '')
{
$lastVisitTime = explode('~', urldecode($lastVisitTime));
foreach ($lastVisitTime as $key => $value) {
$lastVisitTime[$key] = $value;
$lastVisitTime[$key] = strtotime($value);
}
return $this->builder->whereBetween('last_visit_time', $lastVisitTime);
}
public function waiter_id($waiterId)
{
return $this->builder->where('waiter_id', $waiterId);
}
public function user_id($userId)
{
return $this->builder->where('user_id', $userId);
}
public function has_waiter($hasWaiter = 0)
{
if ($hasWaiter) {
return $this->builder->where('waiter_id', '!=', 0);
}
return $this->builder->where('waiter_id', '=', 0);
}
public function in_blacklist($inBlacklist)
{
return $this->builder->where('in_blacklist', $inBlacklist);
}
public function sort($sort = '')
{
$sort = explode(',', $sort);
$field = array_get($sort, 0);
$sort = array_get($sort, 1);
return $this->builder->orderBy($field, $sort);
}
}
\ No newline at end of file
<?php
namespace App\Http\Filters;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
abstract class QueryFilter
{
protected $request;
protected $builder;
protected $size;
public function __construct(Request $request)
{
$this->request = $request;
}
public function apply(Builder $builder)
{
$this->builder = $builder;
foreach ($this->filters() as $name => $value) {
if (method_exists($this, $name) && $value != '') {
call_user_func_array([$this, $name], array_filter([$value]));
}
}
return $this->builder;
}
public function filters()
{
return $this->request->all();
}
}
\ No newline at end of file
<?php
namespace App\Http\Middleware;
use App\Model\RedisModel;
use Closure;
class AuthToken
{
public function __construct()
{
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
$token=$request->input('access_token');
if(empty($token)) return $this->Export(-2,'缺少access_token');
$Redis=new RedisModel();
$appKey=$Redis->get('open_'.$token);
if(empty($appKey)) return $this->Export(-3,'access_token无效,请刷新');
return $next($request);
}
protected function Export($Errcode=0,$ErrMsg='',$dataArr=[]){
if(!empty($dataArr) && !is_array($dataArr)) return json_encode(['errcode'=>-1,'系统错误']);
$data=['errcode'=>$Errcode, 'errmsg'=>$ErrMsg];
if(!empty($dataArr)) foreach ($dataArr as $k=>$v) $data[$k]=$v;
return json_encode($data);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;
class Authenticate
{
/**
* The authentication guard factory instance.
*
* @var \Illuminate\Contracts\Auth\Factory
*/
protected $auth;
/**
* Create a new middleware instance.
*
* @param \Illuminate\Contracts\Auth\Factory $auth
* @return void
*/
public function __construct(Auth $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if ($this->auth->guard($guard)->guest()) {
return response('Unauthorized.', 401);
}
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
class ExampleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
use App\Model\TokenModel;
class UniqueMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//设置唯一追踪值
$request->offsetSet('unique', getUnique(true));
return $next($request);
}
}
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-06-20
* Time: 11:13
*/
function ErrorCode($code = 0, $level = 1){
$systemcode = config('website.SystemCode');
return errCode($code , $level , $systemcode);
}
function SendDingTalk($message){
return SendRobot(config('website.RobotUrl'),$message,[config('website.at')],config('website.SystemName'));
}
function SendErrMsg($e){
return SendAlarm($e,config('website.RobotUrl'),[config('website.at')],config('website.SystemName'));
}
function SendErrMsgApi($e){
if(stripos($e->getFile(),'RouteCollection.php')) return false;
$message='时间:'.date('Y-m-d H:i:s')."\r\n".'任务:'.$e->getFile()."\r\n".'错误信息:'.$e->getMessage()."\r\n".'行号:'.$e->getLine();
SendDingTalkApi($message);
return true;
}
//通过api转发
function SendDingTalkApi($message){
$Url = 'http://api.ichunt.com/public/dingtalkrobot?access_token='.config('website.RobotToken');
$data = array ('msgtype' => 'text','text' => array ('content' => $message."\r\n系统:".config('website.SystemName')));
$data['at']=['atMobiles'=>[config('website.at')]];
$data_string = json_encode($data);
curl($Url, $data_string, true, ['Content-Type:application/json']);
return true;
}
function getFile($url, $save_dir = '', $filename = '', $type = 0)
{
if (trim($url) == '') {
return false;
}
if (trim($save_dir) == '') {
$save_dir = './';
}
if (0 !== strrpos($save_dir, '/')) {
$save_dir .= '/';
}
//创建保存目录
if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
return false;
}
//获取远程文件所采用的方法
if ($type) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);
curl_close($ch);
} else {
ob_start();
readfile($url);
$content = ob_get_contents();
ob_end_clean();
}
//echo $content;
$size = strlen($content);
//文件大小
$fp2 = @fopen($save_dir . $filename, 'a');
fwrite($fp2, $content);
fclose($fp2);
unset($content, $url);
return array(
'file_name' => $filename,
'save_path' => $save_dir . $filename,
'file_size' => $size
);
}
//生成的文件上传到OSS
function SaveDownFile($path=''){
if(empty($path)) return false;
$result=json_decode(UploadToOss($path),true);
if(empty($result['code']) || $result['code'] != 200 || empty($result['data'][0])) return false;
return $result['data'][0];
}
/**
* php上传文件到oss
* @param string $Path 文件路径
* @param array $data
* @return array
* Created on 2018-03-15
*/
function UploadToOss($Path='',$data=[]){
if(empty($Path)) return false;
$field=new CurlFile($Path);
if(!$field) return false;
$data['upload']=$field;
$url=config('website.UploadUrl');
$data['source']=1;
$data['k1']=time();
$data['k2']=MD5(MD5($data['k1']).config('website.UploadKey'));
$data['FileType']='csv';
$result=reportCurl($url,$data,true);
return $result;
}
function unsetArrayToValue($Array,$Field){
if(!is_array($Array)) return false;
if(is_array($Field)){
foreach ($Array as $k=>$v){
if(in_array($v,$Field))
unset($Array[$k]);
}
return $Array;
}else{
foreach ($Array as $k=>$v)
if($v == $Field){
unset($Array[$k]);
return $Array;
}
}
}
//无限极分类
function tree_class_arr($list,$pid=0){
$data=[];
foreach ($list as $k=>$v){
if($v['parent_id']==$pid){
$data[$v['class_id']]=$v;
$return=tree_class_arr($list,$v['class_id']);
if($return){
$data[$v['class_id']]['lower']=$return;
}
}
}
return $data;
}
/**
* [changeUnit description]
* @param [type] $weight [description]
* @param [type] $weightStr [想要转换成的单位 kg g]
* @return [type] [description]
*/
function changeUnit($weight, $weightStr){
if (!isset($weight) || !isset($weightStr)) {
return false;
}
$data = 0;
switch (strval($weightStr)) {
case 'g': // 需要换成克
$data = $weight * 1000;
$data = sctonum($data);
break;
case 'kg': //克转换为千克
$data = $weight / 1000;
$data = sctonum($data);
break;
default:
# code...
break;
}
return $data ? $data : '';
}
/**
* @param $num 科学计数法字符串 如 2.1E-5
* @param int $double 小数点保留位数 默认5位
* @return string
*/
function sctonum($num, $double = 8){
if(false !== stripos($num, "e")){
$a = explode("e",strtolower($num));
return bcmul($a[0], bcpow(10, $a[1], $double), $double);
} else {
return $num;
}
}
//生成识别唯一字段
function MD5GoodsUnique($data){
if(!empty($data['supplier_goods_id'])) return Md5(json_encode([(int)$data['supplier_id'],$data['supplier_goods_id']]));
return Md5(json_encode([(string)strtoupper($data['goods_name']),(int)$data['brand_id'],(int)$data['supplier_id'],(int)$data['packing'],(string)$data['encap']]));
}
\ No newline at end of file
<?php
namespace App\Jobs;
class ExampleJob extends Job
{
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
}
}
<?php
namespace App\Jobs;
use Hhxsv5\LaravelS\Swoole\Timer\CronJob;
class TestCronJob extends CronJob
{
// !!! 定时任务的`interval`和`isImmediate`有两种配置方式(二选一):一是重载对应的方法,二是注册定时任务时传入参数。
// --- 重载对应的方法来返回配置:开始
//这个任务用来自动处理采购员
public function interval()
{
return 1000*60*60*24;// 每12个小时
}
public function isImmediate()
{
return true;// 是否立即执行第一次,false则等待间隔时间后执行第一次
}
// --- 重载对应的方法来返回配置:结束
public function run()
{
}
}
\ No newline at end of file
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
abstract class Job implements ShouldQueue
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use InteractsWithQueue, Queueable, SerializesModels;
}
<?php
namespace App\Listeners;
use App\Events\ExampleEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class ExampleListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param ExampleEvent $event
* @return void
*/
public function handle(ExampleEvent $event)
{
//
}
}
<?php
namespace App\Model;
use App\Http\Filters\QueryFilter;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{
public function scopePage($query, QueryFilter $filters)
{
$params = $filters->filters();
$pageSize = array_get($params, 'page_size',10);
$page = array_get($params, 'page',1);
$pageSize = $pageSize < 50 ? $pageSize : 50;
$query->limit($pageSize)->offset(($page - 1) * $pageSize);
return $filters->apply($query);
}
public function scopeFilter($query, QueryFilter $filters)
{
return $filters->apply($query);
}
}
\ No newline at end of file
<?php
namespace App\Model;
use App\Http\Filters\QueryFilter;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class CustomerModel extends BaseModel
{
public $timestamps = false;
protected $table = 'customer';
//关联模型
public function visits()
{
return $this->hasMany(VisitModel::class, 'user_id', 'user_id');
}
public function last_visit()
{
return $this->hasOne(VisitModel::class,'add_time','last_visit_time');
}
public function customerList($filter)
{
DB::enableQueryLog();
$query = $this::with([
'last_visit'
])->filter($filter);
$countQuery = clone $query;
$list = $query->page($filter)->orderBy('id', 'desc')->get()->toArray();
// dd(DB::getQueryLog());
$count = $countQuery->count();
return ['data' => $list, 'count' => $count];
}
public function getCustomer($userId)
{
$info = $this->where('user_id', $userId)->first();
return $info;
}
//新增客户
public function addCustomer($data)
{
$data['add_time'] = time();
$data['update_time'] = $data['add_time'];
return $this->insert($data);
}
//新增客户
public function saveCustomer($data, $id)
{
$data['update_time'] = time();
return $this->where('id', '=', $id)->update($data);
}
public function changeStatus($userId, $status)
{
return $this->where('user_id', $userId)->update(['status' => $status]);
}
public function updateLastVisitTime($userId)
{
return $this->where('user_id', $userId)->update(['last_visit_time' => time()]);
}
public function getLoginCount($waiterId)
{
$startOfDay = Carbon::now()->startOfDay();
$result = $this->where('last_login_time', '>', $startOfDay)
->where('waiter_id', $waiterId)
->count();
return $result;
}
public function getCustomerCount($waiterId)
{
return $this->where('waiter_id', $waiterId)->count();
}
public function getLongTimeNoVisitCount($waiterId)
{
//目前是15天
$longTime = 15 * 3600 * 24;
$time = time() - $longTime;
if ($waiterId) {
return $this->where('last_visit_time', '<', $time)
->where('waiter_id', $waiterId)->count();
}
return $this->where('last_visit_time', '<', $time)->count();
}
}
\ No newline at end of file
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
<?php
namespace App\Providers;
use App\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
}
}
<?php
namespace App\Providers;
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
}
<?php
namespace App;
use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use Authenticatable, Authorizable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
];
}
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(
'Illuminate\Contracts\Console\Kernel'
);
exit($kernel->handle(new ArgvInput, new ConsoleOutput));
#!/usr/bin/env bash
WORK_DIR=$1
if [ ! -n "${WORK_DIR}" ] ;then
WORK_DIR="."
fi
echo "Restarting LaravelS..."
./bin/laravels restart -d -i
echo "Starting fswatch..."
LOCKING=0
fswatch -e ".*" -i "\\.php$" -m poll_monitor -r ${WORK_DIR} | while read file
do
if [[ ! ${file} =~ .php$ ]] ;then
continue
fi
if [ ${LOCKING} -eq 1 ] ;then
echo "Reloading, skipped."
continue
fi
echo "File ${file} has been modified."
LOCKING=1
./bin/laravels reload
LOCKING=0
done
exit 0
\ No newline at end of file
#!/usr/bin/env php
<?php
$basePath = realpath(__DIR__ . '/../');
include $basePath . '/vendor/autoload.php';
$command = new Hhxsv5\LaravelS\Console\Portal($basePath);
$input = new Symfony\Component\Console\Input\ArgvInput();
$output = new Symfony\Component\Console\Output\ConsoleOutput();
$code = $command->run($input, $output);
exit($code);
\ No newline at end of file
<?php
require_once __DIR__.'/../vendor/autoload.php';
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
$app->withFacades();
/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/
$app->configureMonologUsing(function(Monolog\Logger $monoLog) use ($app){
return $monoLog->pushHandler(
new \Monolog\Handler\RotatingFileHandler($app->storagePath().'/logs/lumen.log',5)
);
});
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
// App\Exceptions\Handler::class
Common\Exceptions\Handler::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
$app->middleware([
// App\Http\Middleware\ExampleMiddleware::class
App\Http\Middleware\UniqueMiddleware::class,
]);
$app->routeMiddleware([
//'auth_token' => App\Http\Middleware\AuthToken::class,
]);
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/
// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(Illuminate\Redis\RedisServiceProvider::class);
$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
$app->register(Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class);
$app->register(Bschmitt\Amqp\LumenServiceProvider::class);
$app->withEloquent();
/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/
$app->configure('website');
$app->configure('database');
$app->configure('errmsg');
$app->configure('amqp');
LogReport::$suffix = '_'.env('LARAVELS_LISTEN_PORT', '');
LogReport::$app_name = env('ELK_NAME');
LogReport::$log_path = realpath(__DIR__ . '/../').'/storage/logs/LogReport/';
require_once __DIR__.'/../app/Http/function.php';
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__.'/../routes/web.php';
});
return $app;
<?php
namespace Common\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response;
use PDOException;
use Predis\Connection\ConnectionException;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
$trace = $e->getTrace();
$class = $trace[0]['class'] ?? '';
$func = $trace[0]['function'] ?? '';
$method = trim($class.'::'.$func, '::');
$report = [
'code' => $this->getCode($e),
'message' => toUtf8($e->getMessage()),
'file' => $e->getFile(),
'line' => $e->getLine(),
'method' => $method,
'request' => json_encode(Request::input()),
'apiUrl' => getUrl(),
'uniqid' => getUnique(true),
];
\LogReport::write(\LogReport::anlyError($report));
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
$code = $this->getCode($e);
//自动区分错误编码返回内容
if (strlen($code) == 6 && substr($code, 0, 1) == 1) {
return Response()->json(['errcode' => $code, 'errmsg' => toUtf8($e->getMessage())]);
}
$msg = '系统错误,请联系客服处理';
$data = '';
if (env('APP_DEBUG', '') == 'true') {
$msg = toUtf8($e->getMessage());
$log = [toUtf8($e->getMessage()), $e->getFile(), $e->getLine()];
$data = implode(" ", $log);
}
$data .= '#'.Request::getMethod();
return Response()->json(['errcode' => $code, 'errmsg' => $msg.' #'.getUnique(true), 'data' => $data]);
// return parent::render($request, $e);
}
private function getCode($e)
{
$systemcode = config('website.SystemCode');
if ($e instanceof PDOException) {//数据库连接
$code = errCode(001, 9, $systemcode);
} elseif ($e instanceof ConnectionException) {//redis连接
$code = errCode(002, 9, $systemcode);
} elseif ($e instanceof FatalThrowableError) {//致命错误
$code = errCode(003, 9, $systemcode);
} elseif ($e instanceof NotFoundHttpException || $e instanceof MethodNotAllowedHttpException) {//404
$code = 404;
} else {
$code = $e->getCode() ? $e->getCode() : 500;
}
return $code;
}
}
<?php
namespace Common\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Redis;
class RedisModel extends Model
{
const WRITE_CONNECT_METHOD = ['set', 'del', 'rpush','lpush', 'expire', 'hset', 'hmset', 'hdel','hsetnx','hincrby'];
const WANRING_LEVEL = 1;
const INGORE_LEVEL = 0;
private $read = [];
private $write = [];
private $level = self::WANRING_LEVEL;
public function __construct($level = self::WANRING_LEVEL, $ConnectWrite = 'default', $ConnectRead = 'read')
{
parent::__construct();
$this->level = $level;
$this->read = Redis::connection($ConnectRead);
$this->write = Redis::connection($ConnectWrite);
}
public function __call($method, $args)
{
$cls = &$this;
$tmp = function($method, $args) use ($cls) {
if (strpos($method, 'pipeline_')) {//使用管道
$method = substr($method, 9);
if (in_array($method, $cls::WRITE_CONNECT_METHOD)) {
return $cls->write->pipeline(function ($pipe) use ($args) {
foreach ($args as $arg) {
$pipe->$method(...$arg);
}
});
} else {
try {
return $cls->read->pipeline(function ($pipe) use ($args) {
foreach ($args as $arg) {
$pipe->$method(...$arg);
}
});
} catch (ConnectionException $e) {
return $cls->write->pipeline(function ($pipe) use ($args) {
foreach ($args as $arg) {
$pipe->$method(...$arg);
}
});
}
}
} else {
if (in_array($method, $cls::WRITE_CONNECT_METHOD)) {
return $cls->write->$method(...$args);
} else {
try {
return $cls->read->$method(...$args);
} catch (ConnectionException $e) {
return $cls->write->$method(...$args);
}
}
}
};
if ($this->level == self::WANRING_LEVEL) {//默认告警级别,抛出异常
if (strpos($method, 'catch_') === 0) {
$method = substr($method, 6);
try {
return $tmp($method, $args);
} catch (\Exception $e) {
return null;
}
} else {
return $tmp($method, $args);
}
} else {
try {
return $tmp($method, $args);
} catch (\Exception $e) {
return null;
}
}
}
//管道
public function pipeline_to_hset($data){
return $this->write->pipeline(function ($pipe) use ($data) {
foreach ($data['data'] as $k => $v) {
$pipe->hset($data['key'],$k,$v);
}
});
}
}
<?php
namespace Rpc\Msg;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;
interface MessageIf {
/**
* @param string $str
* @return string
*/
public function MessageApiAction($str);
}
class MessageClient implements \Rpc\Msg\MessageIf {
protected $input_ = null;
protected $output_ = null;
protected $seqid_ = 0;
public function __construct($input, $output=null) {
$this->input_ = $input;
$this->output_ = $output ? $output : $input;
}
public function MessageApiAction($str)
{
$this->send_MessageApiAction($str);
return $this->recv_MessageApiAction();
}
public function send_MessageApiAction($str)
{
$args = new \Rpc\Msg\Message_MessageApiAction_args();
$args->str = $str;
$bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
if ($bin_accel)
{
thrift_protocol_write_binary($this->output_, 'MessageApiAction', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
}
else
{
$this->output_->writeMessageBegin('MessageApiAction', TMessageType::CALL, $this->seqid_);
$args->write($this->output_);
$this->output_->writeMessageEnd();
$this->output_->getTransport()->flush();
}
}
public function recv_MessageApiAction()
{
$bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Rpc\Msg\Message_MessageApiAction_result', $this->input_->isStrictRead());
else
{
$rseqid = 0;
$fname = null;
$mtype = 0;
$this->input_->readMessageBegin($fname, $mtype, $rseqid);
if ($mtype == TMessageType::EXCEPTION) {
$x = new TApplicationException();
$x->read($this->input_);
$this->input_->readMessageEnd();
throw $x;
}
$result = new \Rpc\Msg\Message_MessageApiAction_result();
$result->read($this->input_);
$this->input_->readMessageEnd();
}
if ($result->success !== null) {
return $result->success;
}
throw new \Exception("MessageApiAction failed: unknown result");
}
}
// HELPER FUNCTIONS AND STRUCTURES
class Message_MessageApiAction_args {
static $isValidate = false;
static $_TSPEC = array(
1 => array(
'var' => 'str',
'isRequired' => false,
'type' => TType::STRING,
),
);
/**
* @var string
*/
public $str = null;
public function __construct($vals=null) {
if (is_array($vals)) {
if (isset($vals['str'])) {
$this->str = $vals['str'];
}
}
}
public function getName() {
return 'Message_MessageApiAction_args';
}
public function read($input)
{
$xfer = 0;
$fname = null;
$ftype = 0;
$fid = 0;
$xfer += $input->readStructBegin($fname);
while (true)
{
$xfer += $input->readFieldBegin($fname, $ftype, $fid);
if ($ftype == TType::STOP) {
break;
}
switch ($fid)
{
case 1:
if ($ftype == TType::STRING) {
$xfer += $input->readString($this->str);
} else {
$xfer += $input->skip($ftype);
}
break;
default:
$xfer += $input->skip($ftype);
break;
}
$xfer += $input->readFieldEnd();
}
$xfer += $input->readStructEnd();
return $xfer;
}
public function write($output) {
$xfer = 0;
$xfer += $output->writeStructBegin('Message_MessageApiAction_args');
if ($this->str !== null) {
$xfer += $output->writeFieldBegin('str', TType::STRING, 1);
$xfer += $output->writeString($this->str);
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
}
class Message_MessageApiAction_result {
static $isValidate = false;
static $_TSPEC = array(
0 => array(
'var' => 'success',
'isRequired' => false,
'type' => TType::STRING,
),
);
/**
* @var string
*/
public $success = null;
public function __construct($vals=null) {
if (is_array($vals)) {
if (isset($vals['success'])) {
$this->success = $vals['success'];
}
}
}
public function getName() {
return 'Message_MessageApiAction_result';
}
public function read($input)
{
$xfer = 0;
$fname = null;
$ftype = 0;
$fid = 0;
$xfer += $input->readStructBegin($fname);
while (true)
{
$xfer += $input->readFieldBegin($fname, $ftype, $fid);
if ($ftype == TType::STOP) {
break;
}
switch ($fid)
{
case 0:
if ($ftype == TType::STRING) {
$xfer += $input->readString($this->success);
} else {
$xfer += $input->skip($ftype);
}
break;
default:
$xfer += $input->skip($ftype);
break;
}
$xfer += $input->readFieldEnd();
}
$xfer += $input->readStructEnd();
return $xfer;
}
public function write($output) {
$xfer = 0;
$xfer += $output->writeStructBegin('Message_MessageApiAction_result');
if ($this->success !== null) {
$xfer += $output->writeFieldBegin('success', TType::STRING, 0);
$xfer += $output->writeString($this->success);
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
}
<?php
namespace Rpc\Msg;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;
interface SendMsgIf {
/**
* @param string $str
* @return string
*/
public function sendMsg($str);
}
class SendMsgClient implements \Rpc\Msg\SendMsgIf {
protected $input_ = null;
protected $output_ = null;
protected $seqid_ = 0;
public function __construct($input, $output=null) {
$this->input_ = $input;
$this->output_ = $output ? $output : $input;
}
public function sendMsg($str)
{
$this->send_sendMsg($str);
return $this->recv_sendMsg();
}
public function send_sendMsg($str)
{
$args = new \Rpc\Msg\SendMsg_sendMsg_args();
$args->str = $str;
$bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
if ($bin_accel)
{
thrift_protocol_write_binary($this->output_, 'sendMsg', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
}
else
{
$this->output_->writeMessageBegin('sendMsg', TMessageType::CALL, $this->seqid_);
$args->write($this->output_);
$this->output_->writeMessageEnd();
$this->output_->getTransport()->flush();
}
}
public function recv_sendMsg()
{
$bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Rpc\Msg\SendMsg_sendMsg_result', $this->input_->isStrictRead());
else
{
$rseqid = 0;
$fname = null;
$mtype = 0;
$this->input_->readMessageBegin($fname, $mtype, $rseqid);
if ($mtype == TMessageType::EXCEPTION) {
$x = new TApplicationException();
$x->read($this->input_);
$this->input_->readMessageEnd();
throw $x;
}
$result = new \Rpc\Msg\SendMsg_sendMsg_result();
$result->read($this->input_);
$this->input_->readMessageEnd();
}
if ($result->success !== null) {
return $result->success;
}
throw new \Exception("sendMsg failed: unknown result");
}
}
// HELPER FUNCTIONS AND STRUCTURES
class SendMsg_sendMsg_args {
static $isValidate = false;
static $_TSPEC = array(
1 => array(
'var' => 'str',
'isRequired' => false,
'type' => TType::STRING,
),
);
/**
* @var string
*/
public $str = null;
public function __construct($vals=null) {
if (is_array($vals)) {
if (isset($vals['str'])) {
$this->str = $vals['str'];
}
}
}
public function getName() {
return 'SendMsg_sendMsg_args';
}
public function read($input)
{
$xfer = 0;
$fname = null;
$ftype = 0;
$fid = 0;
$xfer += $input->readStructBegin($fname);
while (true)
{
$xfer += $input->readFieldBegin($fname, $ftype, $fid);
if ($ftype == TType::STOP) {
break;
}
switch ($fid)
{
case 1:
if ($ftype == TType::STRING) {
$xfer += $input->readString($this->str);
} else {
$xfer += $input->skip($ftype);
}
break;
default:
$xfer += $input->skip($ftype);
break;
}
$xfer += $input->readFieldEnd();
}
$xfer += $input->readStructEnd();
return $xfer;
}
public function write($output) {
$xfer = 0;
$xfer += $output->writeStructBegin('SendMsg_sendMsg_args');
if ($this->str !== null) {
$xfer += $output->writeFieldBegin('str', TType::STRING, 1);
$xfer += $output->writeString($this->str);
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
}
class SendMsg_sendMsg_result {
static $isValidate = false;
static $_TSPEC = array(
0 => array(
'var' => 'success',
'isRequired' => false,
'type' => TType::STRING,
),
);
/**
* @var string
*/
public $success = null;
public function __construct($vals=null) {
if (is_array($vals)) {
if (isset($vals['success'])) {
$this->success = $vals['success'];
}
}
}
public function getName() {
return 'SendMsg_sendMsg_result';
}
public function read($input)
{
$xfer = 0;
$fname = null;
$ftype = 0;
$fid = 0;
$xfer += $input->readStructBegin($fname);
while (true)
{
$xfer += $input->readFieldBegin($fname, $ftype, $fid);
if ($ftype == TType::STOP) {
break;
}
switch ($fid)
{
case 0:
if ($ftype == TType::STRING) {
$xfer += $input->readString($this->success);
} else {
$xfer += $input->skip($ftype);
}
break;
default:
$xfer += $input->skip($ftype);
break;
}
$xfer += $input->readFieldEnd();
}
$xfer += $input->readStructEnd();
return $xfer;
}
public function write($output) {
$xfer = 0;
$xfer += $output->writeStructBegin('SendMsg_sendMsg_result');
if ($this->success !== null) {
$xfer += $output->writeFieldBegin('success', TType::STRING, 0);
$xfer += $output->writeString($this->success);
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
}
<?php
namespace Rpc\Msg;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;
<?php
namespace Rpc;
use Thrift\Exception\TException;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TBufferedTransport;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TPhpStream;
use Thrift\TMultiplexedProcessor;
use Thrift\Protocol\TMultiplexedProtocol;
use Thrift\Factory\TBinaryProtocolFactory;
use Thrift\Factory\TTransportFactory;
use Thrift\Server\TServerSocket;
use Thrift\Server\TSimpleServer;
use Thrift\Server\TForkingServer;
use Thrift\Transport\TSocket;
class MsgRpcClient {
public function sendMsg($data){
try {
ini_set('memory_limit', '1024M');
$socket = new TSocket('192.168.2.245', '9988');
$socket->setRecvTimeout(50000);
$socket->setDebug(true);
$transport = new TBufferedTransport($socket, 1024, 1024);
$protocol = new TBinaryProtocol($transport);
$client = new \Rpc\Msg\SendMsgClient(new TMultiplexedProtocol($protocol, "sendMsg"));
$transport->open();
$result = $client->sendMsg(json_encode($data));
print_r($result);
$transport->close();
} catch (TException $tx) {
print_r($tx->getMessage());
}
}
}
\ No newline at end of file
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/lumen-framework": "5.5.*",
"vlucas/phpdotenv": "~2.2",
"predis/predis": "^1.1",
"illuminate/redis": "^5.5",
"jenssegers/mongodb": "3.3",
"hhxsv5/laravel-s": "~3.4.0",
"bschmitt/laravel-amqp": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~6.0",
"mockery/mockery": "~0.9"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Common\\": "common/"
},
"files": [
"common/function.php",
"common/LogReport.php"
]
},
"autoload-dev": {
"classmap": [
"tests/",
"database/"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"optimize-autoloader": true,
"repositories": {
"packagist": {
"type": "composer",
"url": "https://mirrors.aliyun.com/composer/"
}
}
}
This diff could not be displayed because it is too large.
<?php
return [
/*
|--------------------------------------------------------------------------
| Define which configuration should be used
|--------------------------------------------------------------------------
*/
'use' => 'production',
/*
|--------------------------------------------------------------------------
| AMQP properties separated by key
|--------------------------------------------------------------------------
*/
'properties' => [
'production' => [
'host' => env('RABBITMQ_HOST'),
'port' => 5672,
'username' => env('RABBITMQ_LOGIN'),
'password' => env('RABBITMQ_PASSWORD'),
'vhost' => '/',
'connect_options' => [],
'ssl_options' => [],
'exchange' => env('RABBITMQ_EXCHANGE'),
'exchange_type' => 'direct',
'exchange_passive' => false,
'exchange_durable' => true,
'exchange_auto_delete' => false,
'exchange_internal' => false,
'exchange_nowait' => false,
'exchange_properties' => [],
'queue_force_declare' => false,
'queue_passive' => false,
'queue_durable' => true,
'queue_exclusive' => false,
'queue_auto_delete' => false,
'queue_nowait' => false,
'queue_properties' => [],
'consumer_tag' => '',
'consumer_no_local' => false,
'consumer_no_ack' => false,
'consumer_exclusive' => false,
'consumer_nowait' => false,
'timeout' => 0,
'persistent' => false,
'qos' => false,
'qos_prefetch_size' => 0,
'qos_prefetch_count' => 1,
'qos_a_global' => false
],
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
],
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', base_path('database/database.sqlite')),
'prefix' => env('DB_PREFIX', ''),
],
'mysql' => [
'driver' => 'mysql',
'read' => [
'host' => env('DB_HOST_R')
],
'write' => [
'host' => env('DB_HOST_W')
],
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_PREFIX', ''),
'sticky' => true,//防止主从同步不及时
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'cms' => [
'driver' => 'mysql',
'read' => [
'host' => env('DB_CMS_HOST_R')
],
'write' => [
'host' => env('DB_CMS_HOST_W')
],
'port' => env('DB_CMS_PORT', 3306),
'database' => env('DB_CMS_DATABASE', 'forge'),
'username' => env('DB_CMS_USERNAME', 'forge'),
'password' => env('DB_CMS_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_CMS_PREFIX', ''),
'sticky' => true,//防止主从同步不及时
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 5432),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
'schema' => env('DB_SCHEMA', 'public'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => env('REDIS_CLUSTER', false),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0
],
'read' =>[
'host' => env('REDIS_READ_HOST', ''),
'password' => env('REDIS_READ_PASSWORD', null),
'port' => env('REDIS_READ_PORT', 6379),
'database' => 0
]
],
];
<?php
return [
'cn' => [
-1 => '系统错误',
0 => 'ok',
111001 => '参数错误',
511001 => '新增失败',
511002 => '更新失败',
511003 => '删除失败',
],
];
<?php
/**
* @see https://github.com/hhxsv5/laravel-s/blob/master/Settings-CN.md Chinese
* @see https://github.com/hhxsv5/laravel-s/blob/master/Settings.md English
*/
return [
'listen_ip' => env('LARAVELS_LISTEN_IP', '0.0.0.0'),//swoole监听的地址
'listen_port' => env('LARAVELS_LISTEN_PORT', 60002),//swoole监听的端口
'socket_type' => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : 1,
'enable_coroutine_runtime' => false,
'server' => env('LARAVELS_SERVER', 'LaravelS'),
'handle_static' => env('LARAVELS_HANDLE_STATIC', false),
'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()),
'inotify_reload' => [
'enable' => env('LARAVELS_INOTIFY_RELOAD', false),
'watch_path' => base_path(),
'file_types' => ['.php'],
'excluded_dirs' => [],
'log' => true,
],
'event_handlers' => [],
'websocket' => [
'enable' => false,
//'handler' => XxxWebSocketHandler::class,
],
'sockets' => [],
'processes' => [],
'timer' => [
'enable' => env('timer' , false),
'jobs' => [
// Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab
//\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class,
// Two ways to configure parameters:
// [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering
// \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration
],
'pid_file' => storage_path('laravels-timer.pid'),
'max_wait_time' => 60,
],
'events' => [],
'swoole_tables' => [],
'register_providers' => [],
'cleaners' => [
//Hhxsv5\LaravelS\Illuminate\Cleaners\SessionCleaner::class, // If you use the session/authentication in your project, please uncomment this line
//Hhxsv5\LaravelS\Illuminate\Cleaners\AuthCleaner::class, // If you use the authentication/passport in your project, please uncomment this line
//Hhxsv5\LaravelS\Illuminate\Cleaners\JWTCleaner::class, // If you use the package "tymon/jwt-auth" in your project, please uncomment this line
// ...
],
'swoole' => [
'daemonize' => env('LARAVELS_DAEMONIZE', false),
'dispatch_mode' => 2,
'reactor_num' => function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 4,
'worker_num' => function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8,
'task_worker_num' => function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8,
'task_ipc_mode' => 1,
'task_max_request' => 8000,
'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'max_request' => 8000,
'open_tcp_nodelay' => true,
'pid_file' => storage_path('laravels.pid'),
'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
'log_level' => 4,
'document_root' => base_path('public'),
'buffer_output_size' => 2 * 1024 * 1024,
'socket_buffer_size' => 128 * 1024 * 1024,
'package_max_length' => 4 * 1024 * 1024,
'reload_async' => true,
'max_wait_time' => 60,
'enable_reuse_port' => true,
'enable_coroutine' => false,
'http_compression' => false,
/**
* More settings of Swoole
* @see https://wiki.swoole.com/wiki/page/274.html Chinese
* @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration English
*/
],
];
<?php
return [
'status' => [ // 公司类型
1 => '启用',
2 => '禁用',
],
];
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-03-29
* Time: 10:58
*/
return [
'SystemCode' => env('SYSTEM_CODE','00'),//系统编码,需要在tapd维护,请勿占用已使用的编码
'SystemName' => env('SYSTEM_NAME','这家伙没设置系统'),//系统名称
"RobotUrl" => 'https://oapi.dingtalk.com/robot/send?access_token=92917a6e090a8a39832c4843a579d6c6f9dfecc46fa275f8753ddee2b4399045',
"RobotToken" => '92917a6e090a8a39832c4843a579d6c6f9dfecc46fa275f8753ddee2b4399045',
"at" => env('AT'),
];
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
];
});
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call('UsersTableSeeder');
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/app.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();
# Lumen PHP Framework
[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework)
[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework)
[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework)
[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework)
[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework)
Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.
## Official Documentation
Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs).
## Security Vulnerabilities
If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
## License
The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$router->get('/', function () use ($router) {
return $router->app->version();
});
<?php
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->get('/');
$this->assertEquals(
$this->app->version(), $this->response->getContent()
);
}
}
<?php
abstract class TestCase extends Laravel\Lumen\Testing\TestCase
{
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
{
return require __DIR__.'/../bootstrap/app.php';
}
}
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit5c9707cde9ea4e3942300fe24293f04f::getLoader();
#!/usr/bin/env sh
dir=$(cd "${0%[/\\]*}" > /dev/null; cd '../hhxsv5/laravel-s/bin' && pwd)
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/fswatch" "$@"
#!/usr/bin/env sh
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../phpunit/phpunit" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
fi
"${dir}/phpunit" "$@"
@ECHO OFF
setlocal DISABLEDELAYEDEXPANSION
SET BIN_TARGET=%~dp0/../phpunit/phpunit/phpunit
php "%BIN_TARGET%" %*
#!/usr/bin/env sh
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../nesbot/carbon/bin" && pwd)
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/upgrade-carbon" "$@"
@ECHO OFF
setlocal DISABLEDELAYEDEXPANSION
SET BIN_TARGET=%~dp0/../nesbot/carbon/bin/upgrade-carbon
php "%BIN_TARGET%" %*
/.idea
/vendor
composer.lock
\ No newline at end of file
language: php
php:
- 7.0
- 7.1
before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev
# script: build.sh
# script: phpunit --configuration phpunit.xml --coverage-text
The MIT License (MIT)
Copyright (c) 2015 Björn Schmitt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# bschmitt/laravel-amqp
AMQP wrapper for Laravel and Lumen to publish and consume messages especially from RabbitMQ
[![Build Status](https://travis-ci.org/bschmitt/laravel-amqp.svg?branch=master)](https://travis-ci.org/bschmitt/laravel-amqp)
[![Latest Stable Version](https://poser.pugx.org/bschmitt/laravel-amqp/v/stable.svg)](https://packagist.org/packages/bschmitt/laravel-amqp)
[![License](https://poser.pugx.org/bschmitt/laravel-amqp/license.svg)](https://packagist.org/packages/bschmitt/laravel-amqp)
## Features
- Advanced queue configuration
- Add message to queues easily
- Listen queues with useful options
## Installation
### Composer
Add the following to your require part within the composer.json:
```js
"bschmitt/laravel-amqp": "2.*" (Laravel >= 5.5)
"bschmitt/laravel-amqp": "1.*" (Laravel < 5.5)
```
```batch
$ php composer update
```
or
```
$ php composer require bschmitt/laravel-amqp
```
## Integration
### Lumen
Create a **config** folder in the root directory of your Lumen application and copy the content
from **vendor/bschmitt/laravel-amqp/config/amqp.php** to **config/amqp.php**.
Adjust the properties to your needs.
```php
return [
'use' => 'production',
'properties' => [
'production' => [
'host' => 'localhost',
'port' => 5672,
'username' => 'username',
'password' => 'password',
'vhost' => '/',
'exchange' => 'amq.topic',
'exchange_type' => 'topic',
'consumer_tag' => 'consumer',
'ssl_options' => [], // See https://secure.php.net/manual/en/context.ssl.php
'connect_options' => [], // See https://github.com/php-amqplib/php-amqplib/blob/master/PhpAmqpLib/Connection/AMQPSSLConnection.php
'queue_properties' => ['x-ha-policy' => ['S', 'all']],
'exchange_properties' => [],
'timeout' => 0
],
],
];
```
Register the Lumen Service Provider in **bootstrap/app.php**:
```php
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
*/
//...
$app->configure('amqp');
$app->register(Bschmitt\Amqp\LumenServiceProvider::class);
//...
```
Add Facade Support for Lumen 5.2+
```php
//...
$app->withFacades();
class_alias(\Illuminate\Support\Facades\App::class, 'App');
//...
```
### Laravel
Open **config/app.php** and add the service provider and alias:
```php
'Bschmitt\Amqp\AmqpServiceProvider',
```
```php
'Amqp' => 'Bschmitt\Amqp\Facades\Amqp',
```
## Publishing a message
### Push message with routing key
```php
Amqp::publish('routing-key', 'message');
```
### Push message with routing key and create queue
```php
Amqp::publish('routing-key', 'message' , ['queue' => 'queue-name']);
```
### Push message with routing key and overwrite properties
```php
Amqp::publish('routing-key', 'message' , ['exchange' => 'amq.direct']);
```
## Consuming messages
### Consume messages, acknowledge and stop when no message is left
```php
Amqp::consume('queue-name', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
$resolver->stopWhenProcessed();
});
```
### Consume messages forever
```php
Amqp::consume('queue-name', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
});
```
### Consume messages, with custom settings
```php
Amqp::consume('queue-name', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
}, [
'timeout' => 2,
'vhost' => 'vhost3'
]);
```
## Fanout example
### Publishing a message
```php
\Amqp::publish('', 'message' , [
'exchange_type' => 'fanout',
'exchange' => 'amq.fanout',
]);
```
### Consuming messages
```php
\Amqp::consume('', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
}, [
'exchange' => 'amq.fanout',
'exchange_type' => 'fanout',
'queue_force_declare' => true,
'queue_exclusive' => true,
'persistent' => true// required if you want to listen forever
]);
```
## Credits
* Some concepts were used from https://github.com/mookofe/tail
## License
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
{
"name": "bschmitt/laravel-amqp",
"description": "AMQP wrapper for Laravel and Lumen to publish and consume messages",
"keywords": [
"laravel",
"lumen",
"laravel5",
"rabbitmq",
"amqp",
"queue",
"package",
"message queue",
"Björn Schmitt",
"bschmitt"
],
"license": "MIT",
"support": {
"issues": "https://github.com/bschmitt/laravel-amqp/issues",
"source": "https://github.com/bschmitt/laravel-amqp"
},
"authors": [
{
"name": "Björn Schmitt",
"email": "code@bjoern.io"
}
],
"require": {
"php": ">=7.0",
"php-amqplib/php-amqplib": ">=2.9",
"illuminate/support": ">=v5.5.28"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"mockery/mockery": "~0.9",
"squizlabs/php_codesniffer": "^3.0@dev"
},
"autoload": {
"psr-4": {
"Bschmitt\\Amqp\\": "src/",
"Bschmitt\\Amqp\\Test\\": "test/"
}
},
"extra": {
"laravel": {
"providers": [
"Bschmitt\\Amqp\\AmqpServiceProvider"
],
"aliases": {
"Amqp": "Bschmitt\\Amqp\\Facades\\Amqp"
}
}
},
"minimum-stability": "dev"
}
<?php
return [
/*
|--------------------------------------------------------------------------
| Define which configuration should be used
|--------------------------------------------------------------------------
*/
'use' => 'production',
/*
|--------------------------------------------------------------------------
| AMQP properties separated by key
|--------------------------------------------------------------------------
*/
'properties' => [
'production' => [
'host' => 'localhost',
'port' => 5672,
'username' => '',
'password' => '',
'vhost' => '/',
'connect_options' => [],
'ssl_options' => [],
'exchange' => 'amq.topic',
'exchange_type' => 'topic',
'exchange_passive' => false,
'exchange_durable' => true,
'exchange_auto_delete' => false,
'exchange_internal' => false,
'exchange_nowait' => false,
'exchange_properties' => [],
'queue_force_declare' => false,
'queue_passive' => false,
'queue_durable' => true,
'queue_exclusive' => false,
'queue_auto_delete' => false,
'queue_nowait' => false,
'queue_properties' => ['x-ha-policy' => ['S', 'all']],
'consumer_tag' => '',
'consumer_no_local' => false,
'consumer_no_ack' => false,
'consumer_exclusive' => false,
'consumer_nowait' => false,
'timeout' => 0,
'persistent' => false,
'qos' => false,
'qos_prefetch_size' => 0,
'qos_prefetch_count' => 1,
'qos_a_global' => false
],
],
];
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
\ No newline at end of file
<?php
namespace Bschmitt\Amqp;
use Closure;
use Bschmitt\Amqp\Request;
use Bschmitt\Amqp\Message;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Amqp
{
/**
* @param string $routing
* @param mixed $message
* @param array $properties
*/
public function publish($routing, $message, array $properties = [])
{
$properties['routing'] = $routing;
/* @var Publisher $publisher */
$publisher = app()->make('Bschmitt\Amqp\Publisher');
$publisher
->mergeProperties($properties)
->setup();
if (is_string($message)) {
$message = new Message($message, ['content_type' => 'text/plain', 'delivery_mode' => 2]);
}
$publisher->publish($routing, $message);
Request::shutdown($publisher->getChannel(), $publisher->getConnection());
}
/**
* @param string $queue
* @param Closure $callback
* @param array $properties
* @throws Exception\Configuration
*/
public function consume($queue, Closure $callback, $properties = [])
{
$properties['queue'] = $queue;
/* @var Consumer $consumer */
$consumer = app()->make('Bschmitt\Amqp\Consumer');
$consumer
->mergeProperties($properties)
->setup();
$consumer->consume($queue, $callback);
Request::shutdown($consumer->getChannel(), $consumer->getConnection());
}
/**
* @param string $body
* @param array $properties
* @return \Bschmitt\Amqp\Message
*/
public function message($body, $properties = [])
{
return new Message($body, $properties);
}
}
<?php
namespace Bschmitt\Amqp;
use Bschmitt\Amqp\Consumer;
use Bschmitt\Amqp\Publisher;
use Illuminate\Support\ServiceProvider;
class AmqpServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp');
if (!class_exists('Amqp')) {
class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp');
}
$this->publishes([
__DIR__.'/../config/amqp.php' => config_path('amqp.php'),
]);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('Bschmitt\Amqp\Publisher', function ($app) {
return new Publisher(config());
});
$this->app->singleton('Bschmitt\Amqp\Consumer', function ($app) {
return new Consumer(config());
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['Amqp', 'Bschmitt\Amqp\Publisher', 'Bschmitt\Amqp\Consumer'];
}
}
<?php
namespace Bschmitt\Amqp;
use Illuminate\Config\Repository;
use Closure;
use PhpAmqpLib\Exception\AMQPTimeoutException;
use PhpAmqpLib\Message\AMQPMessage;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Consumer extends Request
{
/**
* @var int
*/
protected $messageCount = 0;
/**
* @param string $queue
* @param Closure $closure
* @return bool
* @throws \Exception
*/
public function consume($queue, Closure $closure)
{
try {
$this->messageCount = $this->getQueueMessageCount();
if (!$this->getProperty('persistent') && $this->messageCount == 0) {
throw new Exception\Stop();
}
/*
queue: Queue from where to get the messages
consumer_tag: Consumer identifier
no_local: Don't receive messages published by this consumer.
no_ack: Tells the server if the consumer will acknowledge the messages.
exclusive: Request exclusive consumer access, meaning only this consumer can access the queue
nowait:
qos: The consumer-prefetch make it possible to limit the number of unacknowledged messages on a channel (or connection) when consuming.
Or, in other words, don't dispatch a new message to a worker
until it has processed and acknowledged the previous one
callback: A PHP Callback
*/
$object = $this;
if ($this->getProperty('qos')) {
$this->getChannel()->basic_qos(
$this->getProperty('qos_prefetch_size'),
$this->getProperty('qos_prefetch_count'),
$this->getProperty('qos_a_global')
);
}
$this->getChannel()->basic_consume(
$queue,
$this->getProperty('consumer_tag'),
$this->getProperty('consumer_no_local'),
$this->getProperty('consumer_no_ack'),
$this->getProperty('consumer_exclusive'),
$this->getProperty('consumer_nowait'),
function ($message) use ($closure, $object) {
$closure($message, $object);
}
);
// consume
while (count($this->getChannel()->callbacks)) {
$this->getChannel()->wait(null, false,
$this->getProperty('timeout') ? $this->getProperty('timeout') : 0
);
}
} catch (\Exception $e) {
if ($e instanceof Exception\Stop) {
return true;
}
if ($e instanceof AMQPTimeoutException) {
return true;
}
throw $e;
}
return true;
}
/**
* Acknowledges a message
*
* @param AMQPMessage $message
*/
public function acknowledge(AMQPMessage $message)
{
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
if ($message->body === 'quit') {
$message->delivery_info['channel']->basic_cancel($message->delivery_info['consumer_tag']);
}
}
/**
* Rejects a message and requeues it if wanted (default: false)
*
* @param AMQPMessage $message
* @param bool $requeue
*/
public function reject(AMQPMessage $message, $requeue = false)
{
$message->delivery_info['channel']->basic_reject($message->delivery_info['delivery_tag'], $requeue);
}
/**
* Stops consumer when no message is left
*
* @throws Exception\Stop
*/
public function stopWhenProcessed()
{
if (--$this->messageCount <= 0) {
throw new Exception\Stop();
}
}
}
<?php
namespace Bschmitt\Amqp;
use Illuminate\Config\Repository;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
abstract class Context
{
const REPOSITORY_KEY = 'amqp';
/**
* @var array
*/
protected $properties = [];
/**
* Context constructor.
*
* @param Repository $config
*/
public function __construct(Repository $config)
{
$this->extractProperties($config);
}
/**
* @param Repository $config
*/
protected function extractProperties(Repository $config)
{
if ($config->has(self::REPOSITORY_KEY)) {
$data = $config->get(self::REPOSITORY_KEY);
$this->properties = $data['properties'][$data['use']];
}
}
/**
* @param array $properties
* @return $this
*/
public function mergeProperties(array $properties)
{
$this->properties = array_merge($this->properties, $properties);
return $this;
}
/**
* @return array
*/
public function getProperties()
{
return $this->properties;
}
/**
* @param string $key
* @return mixed
*/
public function getProperty($key)
{
return array_key_exists($key, $this->properties) ? $this->properties[$key] : null;
}
/**
* @param string $key
* @param mixed $default
* @return mixed
*/
public function getConnectOption($key, $default = null)
{
$options = $this->getProperty('connect_options');
if (!is_array($options)) {
return $default;
}
return array_key_exists($key, $options) ? $options[$key] : $default;
}
/**
* @return mixed
*/
abstract public function setup();
}
<?php
namespace Bschmitt\Amqp\Exception;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Configuration extends \Exception
{
}
<?php
namespace Bschmitt\Amqp\Exception;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Stop extends \Exception
{
}
<?php
namespace Bschmitt\Amqp\Facades;
use Illuminate\Support\Facades\Facade;
/**
* @author Björn Schmitt <code@bjoern.io>
* @see Bschmitt\Amqp\Amqp
*/
class Amqp extends Facade
{
/**
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Amqp';
}
}
<?php
namespace Bschmitt\Amqp;
use Illuminate\Support\ServiceProvider;
/**
* Lumen Service Provider
*
* @author Björn Schmitt <code@bjoern.io>
*/
class LumenServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
}
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->app->bind('Bschmitt\Amqp\Publisher', function ($app) {
return new Publisher($app->config);
});
$this->app->bind('Bschmitt\Amqp\Consumer', function ($app) {
return new Consumer($app->config);
});
$this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp');
if (!class_exists('Amqp')) {
class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp');
}
}
}
<?php
namespace Bschmitt\Amqp;
use PhpAmqpLib\Message\AMQPMessage;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Message extends AMQPMessage
{
}
<?php
namespace Bschmitt\Amqp;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Publisher extends Request
{
/**
* @param string $routing
* @param Message $message
* @throws Exception\Configuration
*/
public function publish($routing, $message)
{
$this->getChannel()->basic_publish($message, $this->getProperty('exchange'), $routing);
}
}
<?php
namespace Bschmitt\Amqp;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Connection\AMQPSSLConnection;
use PhpAmqpLib\Channel\AMQPChannel;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class Request extends Context
{
/**
* @var AMQPStreamConnection
*/
protected $connection;
/**
* @var AMQPChannel
*/
protected $channel;
/**
* @var array
*/
protected $queueInfo;
/**
*
*/
public function connect()
{
if ($this->getProperty('ssl_options')) {
$this->connection = new AMQPSSLConnection(
$this->getProperty('host'),
$this->getProperty('port'),
$this->getProperty('username'),
$this->getProperty('password'),
$this->getProperty('vhost'),
$this->getProperty('ssl_options'),
$this->getProperty('connect_options')
);
} else {
$this->connection = new AMQPStreamConnection(
$this->getProperty('host'),
$this->getProperty('port'),
$this->getProperty('username'),
$this->getProperty('password'),
$this->getProperty('vhost'),
$this->getConnectOption('insist', false),
$this->getConnectOption('login_method', 'AMQPLAIN'),
$this->getConnectOption('login_response', null),
$this->getConnectOption('locale', 3),
$this->getConnectOption('connection_timeout', 3.0),
$this->getConnectOption('read_write_timeout', 130),
$this->getConnectOption('context', null),
$this->getConnectOption('keepalive', false),
$this->getConnectOption('heartbeat', 60),
$this->getConnectOption('channel_rpc_timeout', 0.0),
$this->getConnectOption('ssl_protocol', null)
);
}
$this->channel = $this->connection->channel();
}
/**
* @throws Exception\Configuration
*/
public function setup()
{
$this->connect();
$exchange = $this->getProperty('exchange');
if (empty($exchange)) {
throw new Exception\Configuration('Please check your settings, exchange is not defined.');
}
/*
name: $exchange
type: topic
passive: false
durable: true // the exchange will survive server restarts
auto_delete: false //the exchange won't be deleted once the channel is closed.
*/
$this->channel->exchange_declare(
$exchange,
$this->getProperty('exchange_type'),
$this->getProperty('exchange_passive'),
$this->getProperty('exchange_durable'),
$this->getProperty('exchange_auto_delete'),
$this->getProperty('exchange_internal'),
$this->getProperty('exchange_nowait'),
$this->getProperty('exchange_properties')
);
$queue = $this->getProperty('queue');
if (!empty($queue) || $this->getProperty('queue_force_declare')) {
/*
name: $queue
passive: false
durable: true // the queue will survive server restarts
exclusive: false // queue is deleted when connection closes
auto_delete: false //the queue won't be deleted once the channel is closed.
nowait: false // Doesn't wait on replies for certain things.
parameters: array // Extra data, like high availability params
*/
/** @var ['queue name', 'message count',] queueInfo */
$this->queueInfo = $this->channel->queue_declare(
$queue,
$this->getProperty('queue_passive'),
$this->getProperty('queue_durable'),
$this->getProperty('queue_exclusive'),
$this->getProperty('queue_auto_delete'),
$this->getProperty('queue_nowait'),
$this->getProperty('queue_properties')
);
$this->channel->queue_bind(
$queue ?: $this->queueInfo[0],
$exchange,
$this->getProperty('routing')
);
}
// clear at shutdown
$this->connection->set_close_on_destruct(true);
}
/**
* @return \PhpAmqpLib\Channel\AMQPChannel
*/
public function getChannel()
{
return $this->channel;
}
/**
* @return AMQPStreamConnection
*/
public function getConnection()
{
return $this->connection;
}
/**
* @return int
*/
public function getQueueMessageCount()
{
if (is_array($this->queueInfo)) {
return $this->queueInfo[1];
}
return 0;
}
/**
* @param AMQPChannel $channel
* @param AMQPStreamConnection $connection
*/
public static function shutdown(AMQPChannel $channel, AMQPStreamConnection $connection)
{
$channel->close();
$connection->close();
}
}
<?php
namespace Bschmitt\Amqp\Test;
use \Mockery;
use Illuminate\Config\Repository;
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
const REPOSITORY_KEY = 'amqp';
protected $configRepository;
protected $defaultConfig;
protected function setUp()
{
$amqpConfig = include dirname(__FILE__).'/../config/amqp.php';
$this->defaultConfig = $amqpConfig['properties'][$amqpConfig['use']];
$config = Mockery::mock('\Illuminate\Config\Repository');
$config->shouldReceive('has')->with(self::REPOSITORY_KEY)->andReturn(true);
$config->shouldReceive('get')->with(self::REPOSITORY_KEY)->andReturn($amqpConfig);
$this->configRepository = $config;
}
protected function tearDown()
{
// necessary for Mockery to check if methods were called and with what arguments
Mockery::close();
}
protected function setProtectedProperty($class, $mock, $propertyName, $value)
{
$reflectionClass = new \ReflectionClass($class);
$channelProperty = $reflectionClass->getProperty($propertyName);
$channelProperty->setAccessible(true);
$channelProperty->setValue($mock, $value);
$channelProperty->setAccessible(false);
}
}
<?php
namespace Bschmitt\Amqp\Test;
use \Mockery;
use Bschmitt\Amqp\Publisher;
use Illuminate\Config\Repository;
/**
* @author Björn Schmitt <code@bjoern.io>
*/
class PublisherTest extends BaseTestCase
{
private $publisherMock;
private $connectionMock;
private $channelMock;
protected function setUp()
{
parent::setUp();
// partial mock of \Bschmitt\Amqp\Publisher
// we want all methods except [connect] to be real
$this->publisherMock = Mockery::mock('\Bschmitt\Amqp\Publisher[connect]', [$this->configRepository]);
// set connection and channel properties
$this->channelMock = Mockery::mock('\PhpAmqpLib\Channel\AMQPChannel');
$this->connectionMock = Mockery::mock('\PhpAmqpLib\Connection\AMQPSSLConnection');
// channel and connection are both protected and without changing the source this was the only way to mock them
$this->setProtectedProperty('\Bschmitt\Amqp\Publisher', $this->publisherMock, 'channel', $this->channelMock);
$this->setProtectedProperty('\Bschmitt\Amqp\Publisher', $this->publisherMock, 'connection', $this->connectionMock);
}
public function testSetupPublisher()
{
$this->connectionMock->shouldReceive('set_close_on_destruct')->with(true)->times(1);
$this->channelMock->shouldReceive('exchange_declare')->with(
$this->defaultConfig['exchange'],
$this->defaultConfig['exchange_type'],
$this->defaultConfig['exchange_passive'],
$this->defaultConfig['exchange_durable'],
$this->defaultConfig['exchange_auto_delete'],
$this->defaultConfig['exchange_internal'],
$this->defaultConfig['exchange_nowait'],
$this->defaultConfig['exchange_properties']
)->times(1);
$this->publisherMock->shouldReceive('connect')->times(1);
$this->publisherMock->setup();
}
public function testPublishShouldAChannelMethodWithProperParams()
{
$routing = 'routing-key';
$message = 'sample-message';
$this->channelMock->shouldReceive('basic_publish')
->with(
$message,
$this->defaultConfig['exchange'],
$routing
)->times(1);
$this->publisherMock->publish($routing, $message);
}
public function testPublishShouldCallAChannelMethodWithCustomExchangeValue()
{
$routing = 'routing-key';
$message = 'sample-message';
$exchange = 'custom-exchange';
$this->publisherMock->mergeProperties(['exchange' => $exchange]);
$this->channelMock->shouldReceive('basic_publish')
->with(
$message,
$exchange,
$routing
)->times(1);
$this->publisherMock->publish($routing, $message);
}
}
<?php
namespace Bschmitt\Amqp\Test;
use \Mockery;
use Bschmitt\Amqp\Request;
use Bschmitt\Amqp\Context;
class RequestTest extends BaseTestCase
{
private $connectionMock;
private $channelMock;
private $requestMock;
protected function setUp()
{
parent::setUp();
$this->channelMock = Mockery::mock('\PhpAmqpLib\Channel\AMQPChannel');
$this->connectionMock = Mockery::mock('\PhpAmqpLib\Connection\AMQPSSLConnection');
// partial mock of \Bschmitt\Amqp\Publisher
// we want all methods except [connect,getChannel] to be real
$this->requestMock = Mockery::mock('\Bschmitt\Amqp\Request[connect,getChannel]', [$this->configRepository]);
// channel and connection are both protected and without changing the source this was the only way to mock them
$this->setProtectedProperty('\Bschmitt\Amqp\Request', $this->requestMock, 'channel', $this->channelMock);
$this->setProtectedProperty('\Bschmitt\Amqp\Request', $this->requestMock, 'connection', $this->connectionMock);
}
/**
* @expectedException Bschmitt\Amqp\Exception\Configuration
*/
public function testIfEmptyExchangeThrowsAnException()
{
$this->requestMock->mergeProperties(['exchange' => '']);
$this->requestMock->shouldReceive('connect');
$this->requestMock->setup();
}
public function testIfQueueGetsDeclaredAndBoundIfInConfig()
{
$queueName = 'amqp-test';
$routing = 'routing-test';
$this->requestMock->mergeProperties([
'queue' => $queueName,
'queue_force_declare' => true,
'routing' => $routing
]);
$this->channelMock->shouldReceive('exchange_declare');
$this->requestMock->shouldReceive('connect');
$this->channelMock->shouldReceive('queue_declare')
->with(
$queueName,
$this->defaultConfig['queue_passive'],
$this->defaultConfig['queue_durable'],
$this->defaultConfig['queue_exclusive'],
$this->defaultConfig['queue_auto_delete'],
$this->defaultConfig['queue_nowait'],
$this->defaultConfig['queue_properties']
)
->andReturn([$queueName, 4])
->times(1);
$this->channelMock->shouldReceive('queue_bind')
->with(
$queueName,
$this->defaultConfig['exchange'],
$routing
)
->times(1);
$this->connectionMock->shouldReceive('set_close_on_destruct')->with(true)->times(1);
$this->requestMock->setup();
}
public function testQueueMessageCountShouldBeZeroIfQueueinfoIsNotSet()
{
$this->assertEquals($this->requestMock->getQueueMessageCount(), 0);
}
public function testQueueMessageCountShouldReturnMessageCount()
{
$messageCount = 4;
$queueInfo = ['queue-name', $messageCount];
$this->setProtectedProperty('\Bschmitt\Amqp\Request', $this->requestMock, 'queueInfo', $queueInfo);
$this->assertEquals($this->requestMock->getQueueMessageCount(), $messageCount);
}
public function testIfChannelAndConnectionAreClosedWhenShutdownIsInvoked()
{
$this->channelMock->shouldReceive('close')->times(1);
$this->connectionMock->shouldReceive('close')->times(1);
$this->requestMock::shutDown($this->channelMock, $this->connectionMock);
}
}
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php',
'1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
'3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php',
'bee9632da3ca00a99623b9c35d0c4f8b' => $vendorDir . '/laravel/lumen-framework/src/helpers.php',
'7039eb1b48735a2a2905d88c22d84a48' => $baseDir . '/common/function.php',
'c71e5a39a1f58c05a11e8537318d6d3d' => $baseDir . '/common/LogReport.php',
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'UpdateHelper\\' => array($vendorDir . '/kylekatarnls/update-helper/src'),
'Mockery' => array($vendorDir . '/mockery/mockery/library'),
'Jenssegers\\Mongodb' => array($vendorDir . '/jenssegers/mongodb/src'),
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Contracts\\Translation\\' => array($vendorDir . '/symfony/translation-contracts'),
'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'),
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'Predis\\' => array($vendorDir . '/predis/predis/src'),
'PhpAmqpLib\\' => array($vendorDir . '/php-amqplib/php-amqplib/PhpAmqpLib'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'MongoDB\\' => array($vendorDir . '/mongodb/mongodb/src'),
'Laravel\\Lumen\\' => array($vendorDir . '/laravel/lumen-framework/src'),
'Illuminate\\View\\' => array($vendorDir . '/illuminate/view'),
'Illuminate\\Validation\\' => array($vendorDir . '/illuminate/validation'),
'Illuminate\\Translation\\' => array($vendorDir . '/illuminate/translation'),
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/support'),
'Illuminate\\Session\\' => array($vendorDir . '/illuminate/session'),
'Illuminate\\Redis\\' => array($vendorDir . '/illuminate/redis'),
'Illuminate\\Queue\\' => array($vendorDir . '/illuminate/queue'),
'Illuminate\\Pipeline\\' => array($vendorDir . '/illuminate/pipeline'),
'Illuminate\\Pagination\\' => array($vendorDir . '/illuminate/pagination'),
'Illuminate\\Http\\' => array($vendorDir . '/illuminate/http'),
'Illuminate\\Hashing\\' => array($vendorDir . '/illuminate/hashing'),
'Illuminate\\Filesystem\\' => array($vendorDir . '/illuminate/filesystem'),
'Illuminate\\Events\\' => array($vendorDir . '/illuminate/events'),
'Illuminate\\Encryption\\' => array($vendorDir . '/illuminate/encryption'),
'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'),
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
'Illuminate\\Console\\' => array($vendorDir . '/illuminate/console'),
'Illuminate\\Config\\' => array($vendorDir . '/illuminate/config'),
'Illuminate\\Cache\\' => array($vendorDir . '/illuminate/cache'),
'Illuminate\\Bus\\' => array($vendorDir . '/illuminate/bus'),
'Illuminate\\Broadcasting\\' => array($vendorDir . '/illuminate/broadcasting'),
'Illuminate\\Auth\\' => array($vendorDir . '/illuminate/auth'),
'Hhxsv5\\LaravelS\\' => array($vendorDir . '/hhxsv5/laravel-s/src'),
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Common/Inflector'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Cron\\' => array($vendorDir . '/mtdowling/cron-expression/src/Cron'),
'Common\\' => array($baseDir . '/common'),
'Bschmitt\\Amqp\\Test\\' => array($vendorDir . '/bschmitt/laravel-amqp/test'),
'Bschmitt\\Amqp\\' => array($vendorDir . '/bschmitt/laravel-amqp/src'),
'App\\' => array($baseDir . '/app'),
'' => array($vendorDir . '/nesbot/carbon/src'),
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit5c9707cde9ea4e3942300fe24293f04f
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit5c9707cde9ea4e3942300fe24293f04f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit5c9707cde9ea4e3942300fe24293f04f', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit5c9707cde9ea4e3942300fe24293f04f::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit5c9707cde9ea4e3942300fe24293f04f::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire5c9707cde9ea4e3942300fe24293f04f($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire5c9707cde9ea4e3942300fe24293f04f($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
This diff could not be displayed because it is too large.
Copyright (c) 2006-2015 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment