pinguo / php-msf-demo Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
运行环境:Docker镜像
运行代码:
namespace App\Controllers;
use PG\MSF\Controllers\Controller;
class Welcome extends Controller
{
public function actionIndex()
{
$divide = 58/100;
$this->output($divide);
}
}
输出结果:0.57999999999999996
期待结果:0.58
后来发现是Docker镜像下的php版本问题。在Docker环境里面运行下面的代码就会出现上述问题。
<?php
$total = 58;
echo json_encode($total/100.00, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
$ php test.php
0.57999999999999996
看来要更新下Docker镜像的PHP版本。
按开发文档,可以进行路由映射配置,但不知道应该怎么样配置?
如下配置在config/params.php 或者 config/docker/params.php
直接访问/users/ask 依然回提示找不到方法
$config['rest']['route']['rules'] = [
'GET,POST /groups' => '/account/profile',
'GET /users/ask' => 'user/apply',
'GET /users' => 'user/index',
'GET /users/uid:\d+' => 'user/view',
'PUT /users/method:\w+' => 'user/',
'DELETE /users/uid:\d+' => 'user/delete',
]
开了Rest\Controller,使用outputJson输出,如果传入的HttpCode是错误的,访问会一直阻塞
use PG\MSF\Rest\Controller;
use App\Models\Demo as DemoModel;
class Redis extends Controller
{
// Redis连接池读写示例
public function actionPoolSetGet()
{
yield $this->getRedisPool('p1')->set('key1', 'val1');
$val = yield $this->getRedisPool('p1')->get('key1');
$this->outputJson($val, "test error", 800);
}
}
[Composer\Downloader\TransportException]
The "https://packagist.phpcomposer.com/p/provider-2018-07%24535756c3b2b6e32
40085a2e1766bdcc101ed2bf03375452f6983e561a9600abc.json" file could not be d
ownloaded (HTTP/1.1 404 Not Found)
操作步骤如下:
git clone [email protected]:pinguo/php-msf-demo.git && cd php-msf-demo
继续 sudo docker run -d --name php-msf -p 8808:8000 -p 2202:22 -v $(pwd):"/home/worker/data/www" registry.cn-hangzhou.aliyuncs.com/pinguo-ops/php-msf-docker
此时返回
登陆容器sshd ssh -p 2202 [email protected]
执行composer install 和 supervisorctl update status如下:
请问docker上面提供的image不能直接用吗,需要先运行项目根目录下的build.sh才行
这个demo直接git下来build无法使用, 只能把代码拷贝到php-msf下面去测试。server.php代码是windows换行符,执行会报错:
[worker@newdev php-msf-demo]$ ./server.php
-bash: ./server.php: /home/worker/php/bin/php^M: bad interpreter: No such file or directory
改为unix换行符,执行没有报错,但无任何反应,启动失败。
[worker@newdev php-msf-demo]$ ./server.php
[worker@newdev php-msf-demo]$
如题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.