extension question,YiiFramework - php

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.

Related

In Codeigniter how to make library wait until view is rendered

I want to show a modal when triggered by my custom class library, but without explicity calling any of its methods from outside.
I would have to wait until view template is loaded.
How can I make my library's methods wait until view is loaded?
As first step I have already added my library to the autoload array.
Did you try Hooks?
Following may work but not sure. Didn't try myself.
$hook['post_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine', 'snacks')
);
Reference - https://codeigniter.com/userguide3/general/hooks.html

Error when installed Yii2

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',
],

Mailgun and Laravel returning T_Double_Arrow error

I am trying to get Mailgun to work as my email provider.
By adding the services.php page into app/config and filling in the credentials, I'm left with this:
<?php
'mailgun' => array(
'domain' => 'domain.com',
'secret' => 'key-removedforprivacy',
),
When I go to execute a Mail:: function, it returns this error:
syntax error, unexpected '=>' (T_DOUBLE_ARROW)
It relates to this line:
'mailgun' => array(
If I remove <?php, it actually gets past this step, but returns the error where it can't find the array with the domain and secret values.
I've copied the code from Laravel's website! Any help would be greatly appreciated.
What you have so far is not valid PHP (The interpreter is correct. It's always correct.)
I think this is what you're trying to do
<?php
return array(
'mailgun' => array(
'domain' => 'domain.com',
'secret' => 'key-removedforprivacy',
),
);

Error setting up YiiMail extension

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

Unable to route with module in ZF2

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);

Categories