I am trying to setup YiiMail and I am having the following error message:
Error 500
Alias "ext.yii-mail.YiiMail" is invalid. Make sure it points to an existing PHP file and the file is readable.enter code here
I have placed the YiiMail extenstion in the following directory:
/myapp/protected/extensions/
/myapp/protected/extensions/mail/
/myapp/protected/extensions/mail/YiiMail.php
/myapp/protected/extensions/mail/YiiMailMessage.php
Can anyone explain why I get this error as it appears to be in the correct extensions directory (with all the other existing extensions)
I've added the following to my config array within the components section:
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'php',
'viewPath' => 'application.views.mail',
'logging' => false,
'dryRun' => false
),
And again the following to the import section of the config array
'import' => array('ext.mail.YiiMailMessage'),
The 'class' array item was incorrect - all good now
Related
I am trying to log a webhook response to a custom log file custom.log which is saved on config/logs/custom.log path. I can easily log the webhook to the debug.log file in the same directory by
Log::debug('my desired logs)
How can I log the same log in the custom.log file. Thank you
// Configure logs/custom.log to receive all levels, but only
// those with `custom` scope.
Log::config('custom', [
'className' => 'File',
'path' => LOGS,
'levels' => [],
'scopes' => ['custom'],
'file' => 'custom.log',
]);
Log::debug('this gets written only to custom.log', ['scope' => ['custom']]);
I've install Yii2 framework using composer but get this error in my browser (on localhost):
Invalid Configuration – yii\base\InvalidConfigException
yii\web\Request::cookieValidationKey must be configured with a secret key.
How can I solve this problem?
There is this problem with basic app now https://github.com/yiisoft/yii2-app-basic/issues/69 where composer install doesn't generate this key.
You need to add this key manually.
Go to /config/web.php.
Edit the line 'cookieValidationKey' => '', to include random string (you can use anything like 'cookieValidationKey' => 'jfsbkjsbfdskjgfdskjbgfsdhjgfajds',
You need to set cookieValidationKey in the config file to a random string. The config file is located under yii/your-projectfolder/config/main-local.php if you are using Yii 2.0 Advanced Template
You need to set cookieValidationKey value in project/config/web.php at line 12.
change at:
'cookieValidationKey' => '',
replace with:
'cookieValidationKey' => 'setyourkey',
That should address the issue.
Try this
open Frontend/ config / main.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'enableCsrfValidation' => true,
// 'cookieValidationKey' => 'xxxxxxx', // if u dont hv key just comment it
],
],
if you have a web.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'cookieValidationKey' => 'your-validation-key',
],
I've created a module, a basic copy of the the albums example given in the ZF2 documentation, however, with the new module, I am not able to access it at all - I'm always given a 404 error. I'm building this on the ZF2 skeleton.
I've got three modules loaded: Application, Frontend and Security.
Both Frontend and Security are duplicates of each other, however, I have thoroughly checked and there is no reference to old code (as I literally copied the module folder and renamed/rewrote references).
The module is also loaded in application.config.php.
Any ideas on what I'm missing?
Module Config:
return array(
'controllers' => array(
'invokables' => array(
'Security\Controller\Security' => 'Security\Controller\SecurityController',
),
),
'router' => array(
'routes' => array(
'security' => array(
'type' => 'segment',
'options' => array(
'route' => '/security[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Security\Controller\Security',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'security' => __DIR__ . '/../view',
),
),
);
I had the same problem while following the skeleton application tutorial (Getting started: A skeleton application). Whenever I would go to the album url in the browser (ZendSkeletonApplication/public/album in my case), I would get a 404 error page but no details on why I got the 404. It wasn't clear to me how I would be able determine why I was getting the 404 when I had double checked everything and was pretty sure I copied and configured the Album module properly. It turned out that I was missing a slash in my route (module.config.php). For example I had 'route' => 'album[/:action][/:id]' instead of 'route' => '/album[/:action][/:id]'.
I was only able to figure it out by intentionally causing errors by misspelling things like making the 'Album\Controller\Albums' instead of 'Album\Controller\Album'in the invokables value, this would cause a stack trace to display which then showed the ZF2 classes that where called on the request. I would continue to misspell, test, and then correct each part of the module.config.php until I was given a clue to what part of the configuration was causing the error.
I'm pretty sure this was not the best way to debug an application's configuration.
There is few things that need to be make sure is:-
You have to add your module in
application.config.php (which you are saying you done it.)
Security\Controller\Security has to be same in default too (which you already has)
One more thing is Your folder structure....
-
Just to doulbe check you have a /MODULE/src/MODULE/Controller/CONTROLLER_FILE_NAME.php
I hope that helps..
I know it is an old post. However another thing to make sure you have in the modules top directory (same directory as the Module.php file) is the "autoload_classmap.php"
file with "<?php return array();?>" inside of it.
A simple tip to know whether your rule has already added correctly to the routes or not, you may check the routes value in the config file inside any working module, as following:
$config = $this->serviceLocator->get('config');
var_dump($config);
I want to copy my zend project "InspectionSys" from one pc to another. I make the proper configuration of zend framework on the other pc, when I try to open my project through this URL
http://localhost/zendapps/InspectionSys/public/visits/visit/get_visits
this error occurs
Message: Invalid controller specified (zendapps)
Request Parameters:
array (
'controller' => 'zendapps',
'action' => 'InspectionSys',
'public' => 'visits',
'visit' => 'get_visits',
'module' => 'default',
)
the mapping of the array options and the values are totally incorrect, what is the problem?
EDIT
The mapping should be
array (
'module' => 'visits',
'controller' => 'visit',
'action' => 'get_visits',
'public' => 'public'
)
You should set a virtual host on your apache server. This is better than the solution proposed by bububaba .
Set up baseUrl in the front controller; set it to zendapps/InspectionSys/public. You'll find details in the documentation.
I use the module user
http://yiiframework.com/extension/yii-user/
then open localhost/testdrive and get an error - trying to get property of non-object
on line - array('url'=>Yii::app()->getModule('user')->loginUrl,
did everything according to instructions from the link
Maybe you should add 'class' parameter to 'user' to configuration in main.php, ie:
'components'=>array(
'user' => array(
'class' => 'application.components.WebUser',
'allowAutoLogin' => true,
'loginUrl' => array('/ua/user/login'),
)...
I figured out why this was happening to me, too. I had put the block at the end of main.php. If you put it at the beginning, the problem goes away.