Yii2 How disable Redis - redis

I made the deply of my application (Yii2) in the production environment of the client and there he uses REDIS in another application (Laravel).
However in my Yii2 application I have nothing using or instantiating REDIS, however when running the error appears below. How do I disable REDIS in the application?
Example web.php
'session' => [
'name' => '_siscoopSessionId',
'savePath' => __DIR__ . '/../runtime',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
UPDATE
My db.php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=srv-probat;dbname=siscoop',
'username' => 'intranet',
'password' => '*****',
'charset' => 'utf8',
];

Solution:
Remove all this code:
'session' => [
'name' => '_appnameSessionId',
'savePath' => DIR . '/../runtime',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],

Related

Why yii 2 mailer not send email?

My yii 2 web config
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.send-box.ru',
'username' => 'sendbox#jobgis.ru',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
My yii 2 controller for send mail
public function actionSpam(){
Yii::$app->mailer->compose()
->setFrom('sendbox#jobgis.ru')
->setTo('jetananas#yandex.ru')
->setSubject('Тема сообщения')
->setTextBody('Текст сообщения')
->setHtmlBody('<b>текст сообщения в формате HTML</b>')
->send();
}
Why mail not sending?
Why mailer not display errors?

Laravel 5.8 LDAP Authentication not working - LdapRecord Package

I'm trying to implements an LDAP authentication in an application for my company. I'm using Laravel 5.8 and the LdapRecord package
I have succeed to connect the application with the LDAP server test see Successfully connected and my to authenticate with openldap to online server its also Successfully. but when i want to do the authentication with active directory to my app it not working , Why who can help me?
Here is my code :
The .env
LDAP_LOGGING=true
LDAP_CONNECTION=default
LDAP_HOST=server
LDAP_PORT=389
LDAP_BASE_DN="dc=mydomain,dc=local"
LDAP_TIMEOUT=5
LDAP_SSL=false
LDAP_TLS=false
The ldap.php
return [
'default' => env('LDAP_CONNECTION', 'default'),
'connections' => [
'default' => [
'hosts' => [env('LDAP_HOST', 'server')],
'username' => env('LDAP_USERNAME', ''),
'password' => env('LDAP_PASSWORD', ''),
'port' => env('LDAP_PORT', 389),
'base_dn' => env('LDAP_BASE_DN', 'dc=mydomain,dc=local'),
'timeout' => env('LDAP_TIMEOUT', 5),
'use_ssl' => env('LDAP_SSL', false),
'use_tls' => env('LDAP_TLS', false),
],
],
'logging' => env('LDAP_LOGGING', true),
'cache' => [
'enabled' => env('LDAP_CACHE', false),
'driver' => env('CACHE_DRIVER', 'file'),
],
];
The auth.php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'ldap',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent' ,
'model' => App \ User :: class,
],
'ldap' => [
'driver' => 'ldap',
'model' => LdapRecord\Models\ActiveDirectory\User::class,
// 'model' => LdapRecord\Models\OpenLDAP\User::class,
'database' => [
'model' => App\User::class,
'sync_passwords' => false,
'sync_attributes' => [
'name' => 'cn',
'email' => 'mail',
],
],
]
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => 10800,
];
The user.php model
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
class User extends Authenticatable implements LdapAuthenticatable
{
use Notifiable, AuthenticatesWithLdap, HasLdapUser ;
protected $fillable = [
'name',
'email',
'password',
];
protected $hidden = [
'password', 'remember_token' ,
];
protected $casts = [
'email_verified_at' => 'datetime',
];
}
The LoginController
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function credentials(Request $request)
{
return [
'uid' => $request->get('username'),
'password' => $request->get('password'),
];
}
public function username()
{
return 'username';
}
}
Is there anyone who has already used this package and can help me on my code ? thank you in advance :)

yii2 custom REST api issue

I have tried all the way to make these run but no use.There is lots of problem and confusion i m going through.
I have make api which return all the countries which is working fine.Now need to write api function to list all the states of perticular country.
api : http://phpserver:8090/ssn-project/newzit/api/web/state/customstate?country_id=102
StateController.php
class StateController extends ActiveController{
public $modelClass = 'api\modules\state\models\State';
public function actionCustomState($country_id)
{
$model = new $this->modelClass;
$result = $model::find()
->where(['country_id' => $country_id])
->all();
return $result;
}
}
main.php
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => ['country/country','state/state','category/category','seller/seller'],
'extraPatterns' => [
'GET CustomState' => 'CustomState',
],
]
],
]
Am I doing anything wrong.Please help
What do you mean by 'controller' => ['country/country','state/state','category/category','seller/seller'] ? This will be treated as module/controller. You have placed all controllers inside different modules? With this logic, your api url will be
http://phpserver:8090/ssn-project/newzit/api/web/state/state/customstate?country_id=102
instead of
http://phpserver:8090/ssn-project/newzit/api/web/state/customstate?country_id=102
Found the solution.
made 'pluralize'=>false and used custom-state in url
My main.php
'rules' => [
[
'pluralize'=>false,
'class' => 'yii\rest\UrlRule',
'controller' => ['country/country','state/state','category/category','seller/seller','contactus/contactus'],
'extraPatterns' => [
'GET custom-state' => 'custom-state',
],
]
],
Thank you.

Module route with rewrite redirect to product on Prestahop

I created a custom route for an artist page:
public function hookModuleRoutes($params)
{
return [
'module-artists-artist' => [
'controller' => 'artist',
'rule' => 'artists/{id_artist}',
'keywords' => [
'id_artist' => ['regexp' => '[0-9]+', 'param' => 'id_artist'],
],
'params' => [
'fc' => 'module',
'module' => 'artists',
'controller' => 'artist'
],
],
];
}
If I test with /artists/1, this works. But I want to add the link_rewrite property. So I modified the configuration like this:
public function hookModuleRoutes($params)
{
return [
'module-artists-artist' => [
'controller' => 'artist',
'rule' => 'artists/{id_artist}-{rewrite}',
'keywords' => [
'id_artist' => ['regexp' => '[0-9]+', 'param' => 'id_artist'],
'rewrite' => ['regexp' => '[_a-zA-Z0-9\pL\pS-]*'],
],
'params' => [
'fc' => 'module',
'module' => 'artists',
'controller' => 'artist'
],
],
];
}
But when I try /artists/1-baxter, I'm redirected to the product page of product with ID 1. My artist controller is never called.
[Debug] This page has moved
Please use the following URL instead: http://localhost:8000/fr/estampes/1-est-ce-que-etre
How can I solve it?
This is because URLs generated by your pattern also match the product URL pattern, which has higherprecedence. PrestaShop doesn't check whether product exists, it just redirects directly to ProductController. Page patterns in PrestaShop differ from each other so that URLs can be quickly recognized to be associated with X controller. You can confirm this by checking the default patterns.
You can check the product URL pattern in back-office: SEO & URLs or in DispatcherCore class. Anyway, if you want an easy fix I'd suggest making this pattern:
artists/{id_artist}/{rewrite}

Zend Framework 2 + Doctrine 2 and Authentication Service

It was successfully working before I changed the authentication service name from 'orm_default' to 'admin', and it is necessary since I have more modules which uses more authentication services.
The problem is I'm getting the following error:
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.authenticationservice.admin'
My module.config.php
'doctrine' => array
(
'driver' => array
(
__NAMESPACE__ . '_driver' => array
(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array
(
'drivers' => array
(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
),
)
),
'authentication' => array
(
'admin' => array
(
'object_manager' => 'Doctrine\ORM\EntityManager',
'identity_class' => __NAMESPACE__ . '\Entity\User',
'identity_property' => 'email',
'credential_property' => 'password',
'credentialCallable' => __NAMESPACE__ . '\Model\User::hashPassword'
),
),
),
My Module.php
public function getServiceConfig()
{
return array
(
'factories' => array
(
'Admin\Auth' => function($sm)
{
return $sm->get('doctrine.authenticationservice.admin');
},
'Admin\Form\Auth\Login' => function($sm)
{
return new Form\Auth\Login();
},
),
);
}
It was confirmed as a bug: https://github.com/doctrine/DoctrineORMModule/issues/291
According to a comment in a doctrine module source file it plans to be fixed in 1.0. In this meantime you can it in your any module.config.php file of your application like this:
'authentication' =>
[
'application' =>
[
'object_manager' => 'Doctrine\ORM\EntityManager',
'identity_class' => 'Application\Entity\Customer',
'identity_property' => 'email',
'credential_property' => 'password',
'credentialCallable' => 'Application\Entity\Customer::hashPassword'
],
],
'authenticationadapter' =>
[
'application' => true,
],
'authenticationstorage' =>
[
'application' => true,
],
'authenticationservice' =>
[
'application' => true,
]
I had exactly same problem when i was working on my project. After working my *ss out for two nights, i solved the problem by simply re-installing the doctrine-orm-module after reading https://github.com/doctrine/DoctrineORMModule, "Registered Service names" section. This simply means doctrine orm module wasn't properly installed, or wasn't installed.