当Apache即将退出时,有没有办法运行命令/方法?
我有一个使用 Xampp 在 Windows 中运行的应用程序(仅限本地使用),并且希望在用户结束此应用程序时执行某种清理方法,这发生在按下 Apache 的停止按钮时。
那么我可以使用 Xampp 或 apache 甚至 php 触发的任何类型的事件?并且命令可以来自 cmd、php 等。
OBS:必须是在 apache 关闭之前的东西,所以检查 Windows 进程列表不是一个选项。
在我目前的项目中,我需要每4秒检查一次S3存储桶内容以获取新文件.
每次使用该服务时,此脚本将运行大约3个小时,并且在一个前缀的末尾将有大约2700个文件.
这是我列出这些文件的功能:
public function listFiles($s3Prefix, $limit, $get_after = ''){
$command = $this->s3Client->getCommand('ListObjects');
$command['Bucket'] = $this->s3_bucket;
$command['Prefix'] = $s3Prefix;
$command['MaxKeys'] = $limit;
$command['Marker'] = $s3Prefix.'/'.$get_after;
//command['Query'] = 'sort_by(Contents,&LastModified)';
$ret_s3 = $this->s3Client->execute($command);
$ret['truncated'] = $ret_s3['IsTruncated'];
$ret['files'] = $ret_s3['Contents'];
return $ret;
}// listFiles
Run Code Online (Sandbox Code Playgroud)
我需要的是获取文件,按LastModified字段排序,所以我不需要获取超过2k的文件.是否有额外的参数,如
command['Query'] = 'sort_by(Contents,&LastModified)';
Run Code Online (Sandbox Code Playgroud)
在php API中添加?
----------已编辑------------
正如Abhishek Meena回答的那样,在shell中可以使用
aws s3api list-objects --bucket "bucket-name" --prefix "some-prefix" --query "Contents[?LastModified>=\`2017-03-08\`]"
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是如何在PHP中实现它.
PHP API: https://github.com/aws/aws-sdk-php
Laravel(5.8) 和 VUE 一起工作得很好,但我的 app.js 变得越来越大。
例如,我有以下 app.js:
window.Vue = require('vue');
window.Vue.component('Comp1', require('./components/Comp1.vue').default);
window.Vue.component('Comp2', require('./components/Comp2.vue').default);
window.Vue.component('Comp3', require('./components/Comp3.vue').default);
window.mainApp = new Vue({
el: '#app'
});
Run Code Online (Sandbox Code Playgroud)
在实际情况下,我有大约 30 个组件 + 第三方,结果是 1.2mb 的 JS 用于生产。
所以,我试图在许多“区域相关”js 中破坏 app.js 文件,只是拆分,所以我会有类似的东西:
应用程序.js:
window.Vue = require('vue');
window.mainApp = new Vue({
el: '#app'
});
Run Code Online (Sandbox Code Playgroud)
appMainComp.js:
window.Vue.component('Comp1', require('./components/Comp1.vue').default);
window.Vue.component('Comp2', require('./components/Comp2.vue').default);
Run Code Online (Sandbox Code Playgroud)
appOtherComp.js:
window.Vue.component('Comp3', require('./components/Comp3.vue').default);
Run Code Online (Sandbox Code Playgroud)
现在,抓住了。我在 app.js “window.mainApp = new Vue({ el: '#app'});”之后注册的所有东西 不要注册。
那么,有没有办法在我的“mainApp”创建后注册一个组件?就像是
mainApp.addComponent('./components/Comp1.vue');
Run Code Online (Sandbox Code Playgroud)
或者任何其他方式来破坏多个文件中的 app.js ?
有没有办法使用AdvancedWebView授予我的 android 应用程序相机访问权限?
本机 webview 是可能的,但本机不允许通过 < input type="file"> 上传文件,所以现在我可以上传文件,但没有摄像头。
主要代码:
public class MainActivity extends ActionBarActivity implements AdvancedWebView.Listener {
private AdvancedWebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (AdvancedWebView) findViewById(R.id.webview);
mWebView.setListener(this, this);
mWebView.setGeolocationEnabled(true);
mWebView.loadUrl(url);
}
}
Run Code Online (Sandbox Code Playgroud)
这
mWebView.setGeolocationEnabled(true);
Run Code Online (Sandbox Code Playgroud)
行给予位置许可就好了,视频有类似的东西吗?
我正在 Laravel 5.2 中做一个使用 websockets 的应用程序。对于 websocket 连接,我使用的是HoaServer,效果很好。
不好的部分是,我不知道如何将此服务器作为控制器,或者至少可以访问我的模型,现在我正在使用单独的 PDO 连接来进行数据库查询。
有人知道是否可以将此服务器作为控制器或至少可以通过 Laravel 模型访问数据库?
我现在的服务器:
require_once(__DIR__.'/../vendor/autoload.php');
$PDO = new PDO('mysql:host=127.0.0.1:3306;dbname=DBNAME', "USER", "PASS");
$websocket = new Hoa\Websocket\Server(new Hoa\Socket\Server('ws://'.$ip.':'.$porta));
$websocket->on('open', function (Hoa\Event\Bucket $bucket) {
return;
});
$websocket->on('message', function (Hoa\Event\Bucket $bucket) {
return;
});
$websocket->on('close', function (Hoa\Event\Bucket $bucket) {
return;
});
$websocket->run();
Run Code Online (Sandbox Code Playgroud)
我最喜欢的是触发laravel 事件,我不知道如何触发。:/
//Socket server message event
$server->on('message', function() {
//Fire your Laravel Event here
});
Run Code Online (Sandbox Code Playgroud)