const spawn = require('child_process').spawn;
(async () => {
const promise = new Promise((resolve, reject) => {
const output = {
data: '',
errors: '',
};
options = [
'code.php',
];
const process = spawn('/opt/homebrew/bin/php', options);
process.stdout.on('data', (data) => {
output.data += data.toString();
});
process.stderr.on('data', (data) => {
output.errors += data.toString();
});
process.on('exit', (code) => {
resolve(output);
});
});
const data = await promise;
console.info(data);
})();
const { ProxyAgent } = require('undici');
const proxy = {
'host': 'xxx.xxx.xxx.xxx',
'port': 'xxx',
'username': 'xxx',
'password': '***',
};
const proxyAgent = new ProxyAgent({
uri: `http://${proxy.host}:${proxy.port}`,
token: `Basic ${Buffer.from(`${proxy.username}:${proxy.password}`).toString('base64')}`,
});
(async () => {
const data = await fetch('https://httpbin.org/get', { dispatcher: proxyAgent });
const json = await data.json();
await proxyAgent.close();
console.log(json);
})();
protected function run($query, $bindings, Closure $callback)
{
$query.= '-- this is test comment';
// остальной код
'file' => 'mimetypes:application/pdf
'file' => 'mimes:application/pdf
<?php
$file = request()->file('file');
$ext = $file->getClientOriginalExtension();
$ext = strtolower($ext);
if (!in_array($ext, ['jpg', 'jpeg', 'png', 'gif'])) {
return response()->json([
'errors' => [
'file' => 'INVALID_EXTENSION',
]
], 400);
}