FFPROBE not supported on window machine - laravel

I'm using the PHP-FFMpeg repository to do some video work inside my Laravel application, but I'm encountering some issues setting it up
ffprobe failed to execute command
return [
'default_disk' => 'local',
'ffmpeg' => [
// 'binaries' => env('FFMPEG_BINARIES', 'ffmpeg'),
'ffmpeg.binaries' => 'C:/binaries/ffmpeg/bin/ffmpeg.exe',
'threads' => 12,
],
'ffprobe' => [
//'binaries' => env('FFPROBE_BINARIES', 'ffprobe'),
'ffprobe.binaries' => 'C:/binaries/ffmpeg/bin/ffprobe.exe',
],
'timeout' => 3600,
];

Related

Cakephp3 Change cache duration in controller

Hello everyone I work with cakephp3 here is my cache configuration in app.php
'Cache' => [
'access_token' => [
'className' => 'File',
'duration' => '+2 minutes',
'path' => CACHE
]
],
I set the duration to 2 minutes but I need to dynamically change the duration via my Controller.
I I tried setConfig but it does not work
Cache::write("access_token_$key", $response, 'access_token');
Cache::setConfig("access_token_$key", array('duration' => $time));
Also i tried this but still does not work
$engine = Cache::engine("access_token_$key");
$engine->config("duration", $time);
Thanks for any help

Memcache not working with Laravel but it's working when using it directly

I have memcached set up on my server.
If I use the following code -
$meminstance = new Memcached();
$meminstance->addServer("127.0.0.1", 11211);
$meminstance->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$meminstance->setSaslAuthData("user", "pass");
$result = $meminstance->get("test");
if ($result) {
echo $result;
} else {
echo "No matching key found. Refresh the browser to add it!";
$meminstance->set("test", "Successfully retrieved the data!") or die("Couldn't save anything to memcached...");
}
then everything works perfectly.
However, if I set the same settings via laravel then the cache does not work at all. When I check debug bar, the cache keeps missing.
.env
MEMCACHED_USERNAME=user
MEMCACHED_PASSWORD=pass
MEMCACHED_HOST=127.0.0.1
MEMCACHED_PORT=11211
config/cache.php
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID', 1),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
//Memcached::OPT_BINARY_PROTOCOL => true,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
What can be the cause of this? I've noticed that if I enter the incorrect credentials or server details, no error appears. Is it possible that Laravel just isn't communicating with the memcached server?
I've managed to fix it by enabling UDP in memcached.
sudo nano /etc/memcached.conf
and remove the line
-U 0

Laravel transient queues and messages

I'm working on Laravel 5.1.46 (LTS) with rabbitmq for message queues with package
.env
QUEUE_DRIVER=rabbitmq
config/queue.php
'rabbitmq' => [
'driver' => 'rabbitmq',
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
'port' => env('RABBITMQ_PORT', 5672),
'vhost' => env('RABBITMQ_VHOST', '/'),
'login' => env('RABBITMQ_LOGIN', 'guest'),
'password' => env('RABBITMQ_PASSWORD', 'guest'),
// name of the default queue,
'queue' => env('RABBITMQ_QUEUE'),
// create the exchange if not exists
'exchange_declare' => true,
// create the queue if not exists and bind to the exchange
'queue_declare_bind' => true,
'queue_params' => [
'passive' => false,
'durable' => true, // false
'exclusive' => false,
'auto_delete' => false,
],
'exchange_params' => [
// more info at http://www.rabbitmq.com/tutorials/amqp-concepts.html
'type' => env('RABBITMQ_EXCHANGE_TYPE', 'direct'),
'passive' => false,
// the exchange will survive server restarts
'durable' => true, // fakse
'auto_delete' => false,
]
I've 8 queues in total. Queue names are stored in .env file.
QUEUE_ONE=queue-one
QUEUE_TWO=queue-two
.
.
.
QUEUE_EIGHT=queue-eight
And while dispatching a job,
dispatch(new Job1())->onQueue(env('QUEUE_ONE'))
Queues and messages are persistent/durable.
Due to some performance issues, I need to change the durability of some queues and their messages. So,
5 queues and their messages will be transient (non-persistent)
3 queues and their messages will be persistent
How it is possible with-in Laravel and rabbitmq ?
Note :
I know, I can set
durable = false
but it will be for all queues,
// config/queue.php
'rabbitmq_durable' => [
'driver' => 'rabbitmq',
// ...
'queue_params' => [
'passive' => false,
'durable' => true,
'exclusive' => false,
'auto_delete' => false,
],
// ...
],
'rabbitmq_not_durable' => [
'driver' => 'rabbitmq',
// ...
'queue_params' => [
'passive' => false,
'durable' => false,
'exclusive' => false,
'auto_delete' => false,
],
// ...
]
Laravel 5.1
To use different configs and different connections on Laravel 5.1 you have to use the Queue fascade:
Queue::connection('rabbitmq_durable')->pushOn('queue_1', TestJob::class);
Queue::connection('rabbitmq_not_durable')->pushOn('queue_6', TestJob::class);
Laravel 5.2+
To use different configs and different connections on Laravel 5.2 and onwards you can use the onConnection() method like so:
TestJob::dispatch()->onQueue('queue_one')->onConnection('rabbitmq_durable');
TestJob::dispatch()->onQueue('queue_six')->onConnection('rabbitmq_not_durable');

Yii2 session expires after user is idle for a fixed seconds despite session timeouts being set to at least 1 day

I have already added these codes in my config/web file
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
'enableSession' => true,
'authTimeout' =>86400,
'loginUrl' => ['account/login'],
],
'session' => [
'timeout' => 86400,
],
After session expires I want to automatically logout and redirect to login action.
Make sure in your php.ini file
config
session.gc_maxlifetime
by default set as :
session.gc_maxlifetime=1440
change it, to :
session.gc_maxlifetime=86400
Very first you have to set 'enableAutoLogin' => false, .
now add these lines there in your config/web.
I have added it in frontend/config/main.php because I am using frontend only.
'components' => [
...
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => false,
'enableSession' => true,
'authTimeout' => 1800, //30 minutes
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'class' => 'yii\web\Session',
'name' => 'advanced-frontend',
'timeout' => 1800,
],
...
Now go to yii2/web/User.php and write code for destroy session in logout method before return as guest()-
public function logout($destroySession = true)
{
$identity = $this->getIdentity();
if ($identity !== null && $this->beforeLogout($identity)) {
......
if ($destroySession && $this->enableSession) {
Yii::$app->getSession()->destroy();
}
$this->afterLogout($identity);
}
$session = Yii::$app->session;
$session->remove('other.id');
$session->remove('other.name');
// (or) if is optional if above won't works
unset($_SESSION['class.id']);
unset($_SESSION['class.name']);
// (or) if is optional if above won't works
unset($session['other.id']);
unset($session['other.name']);
return $this->getIsGuest();
}
For me it worked great.

Installing user-management for Yii2.0

I've been trying to install user-management for Yii2.0, but getting ReflectionException while loading the page. I have attached the error page and directory structure below.
and the file path is as shown below.
I've searched a lot to find out the reason for this, but nothing worked out. can someone tell me what am I missing here to get it work. looks like the user-management installation documentation has some flaws. It is not clear enough to understand. Hope to get the steps to install. Thanks
Here is my console/web.php
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'gAry7SfUr0oOjNQDqItsobmGBcJajQoW',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
//'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
'class' => 'app\webvimark\modules\user-management\components\UserConfig',
// Comment this if you don't want to record user logins
'on afterLogin' => function($event) {
\webvimark\modules\user-management\models\UserVisitLog::newVisitor($event->identity->id);
}
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
],
'modules'=>[
'user-management' => [
'class' => 'webvimark\modules\user-management\UserManagementModule',
// 'enableRegistration' => true,
// Here you can set your handler to change layout for any controller or action
// Tip: you can use this event in any module
'on beforeAction'=>function(yii\base\ActionEvent $event) {
if ( $event->action->uniqueId == 'user-management/auth/login' )
{
$event->action->controller->layout = 'loginLayout.php';
};
},
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
It seems to have a slight difference with the expected configuration for this extension.
Use this
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
ie UserManagement instead of user-management is a configuration path and not a route

Resources