CConsoleApplication.defaultController not defined when creating new migration - yii

I'm trying to use the yii migration system but I'm stuck on this error when I execute this commande:
yiic migrate create add_table_test
I get this error:
exception 'CException' with message 'Property CConsoleApplication.defaultController" is not defined'
(CCompenent.php:173)
But I've defined a defaultController in my config file:
'basePath'=>$rootPath,
'defaultController' => 'person/index',
'homeUrl'=>array('/me'),
I spent hours looking on Google, but I can't find a solution.
Does anyone have an idea about this problem?

The problem is, that you've actually defined the property defaultController in your config/console.php but as the error message says the CConsoleApplication has no such property.
So just remove defaultController from your console config.

(this is actually an answer given by OP (Michaƫl). I'm putting it here, because he put it into question)
It turned out, that the problem was on my side. I did a really bad thing.
Problem was solved by:
Replacing in yiic.php line $config=dirname(__FILE__).'/config/dev.php'; with $config=dirname(__FILE__).'/config/console.php';.
Create a console.php file in the config directory, without defaultController and theme option.

Related

Syntax error handling in dojo 18n resource file

require(["dojo/i18n!myapp/nls/extTools_i18nStrings"],function(extTools_i18nStrings){
// Do something with the loaded file
});
If the resource file (extTools_i18nStrings) has syntax error, it will be shown in dojo.js. How can I handle it in my code?
Try catch block did not work.
Thanks in advance.
Error: Script error .............dojo.js:15
The quick answer is you don't want to. The right thing to do is fix the bundle. This is the same as having errors in your application code, and you would not expect the code to 'handle' that.
But since i18n is an AMD plugin running as part of the loader (which is why you can't try/catch it), the error might be reported through the AMD micro event API, and you could use that to show a better error. I'm not sure how you 'handle' this syntax error other than showing an error.
If you can't control the quality of the bundles via some part of your development or build process you'd have to invent your own alternative to dojo/i18n and you probably don't want to go down that route for all of your bundles.

Enabling REST on HMVC CodeIgniter setup

I have just finished setting up an HMVC CodeIgniter following the steps here.
I am now trying to create a module "api" which I wish to use Phil Sturgeon's REST library.
It states here that I need to extend the MX_Controller rather than the CI_Controller and I did.
My initial setup was like this
application
--modules
----api
------config
------controller
------libraries
I kept getting an error with loading Rest_Controller so I have tried moving the REST_Controller and Format libraries to application/libraries that seemed to fix the loading issue but now i am getting the error below whenever i try to access it via http://example.com/codeigniter/index.php/api/example/user/id/1/format/json
"An Error Was Encountered
Unable to load the requested class: security"
I am expecting for the output to be "{"id":1,"name":"Some Guy","email":"example1#example.com","fact":"Loves swimming"}"
What am I missing? Would it be possible to keep the REST_Controller and Format libraries under the api module? If so, how?
Source
Open Rest_Controller.php go to line 173 and change the following code
$this->load->library('security');
to
$this->load->helper('security');
EDIT:
To have the REST_Controller and Format libraries under the api module.
Move the REST_Controller to api/controllers/REST_Controller.php and Format to api/libraries/Format.php

Kohana: Using auth module of php-activerecord, but seeing error as " Class 'Arm' not found"

I am using PHP-activerecord in kohana and using its auth module by calling function :
User::create_user("Name", "Name", "Name", "Name");
But seeing error : ErrorException [ Fatal Error ]: Class 'Arm' not found
I have added kohana-activerecord in bootstrap.php and also enabled Auth module. arm.php is in kohana-activerecord/classes/.
Can someone please help understand how to locate Class arm and remove this error. This will be of great help.
Assuming you're using https://github.com/devi/kohana-activerecord, the simplest answer is to load the class manually.
require_once('/kohana-activerecord/classes/arm.php') in your code, and do that until you have all of your dependencies loaded. I'm not entirely sure how the Kohana-Auth library is meant to load properly, and it has no real useful documentation on its github page. But I'll assume just manually loading the classes will be fine as it hasn't been updated for a couple years.

Undefined method stdClass::user() error when using CakePHP Auth

I'm fairly new to CakePHPand am building a site using the Auth component. A couple of times I have tried to do things with this component which have caused the error
Fatal error: Call to undefined method stdClass::user() in /ftphome/site/app/controllers/users_controller.php on line 395
The line it refers to in this case is
$this->User->read(null, $this->Auth->user('id'));
This error does not disappear when I revert the code back to how it was before the error and I only seem to be able to get rid of it by removing some files on the server (I'm not sure which files, when I tried removing all files in the tmp directory the error persisted so I removed the entire site and restored from the latest svn revesion.
In this particular case I think I caused the error by putting the following code in app_controller
class AppController extends Controller {
function beforeRender() {
$this->set('test', $this->Auth->user());
}
}
Which I copied from this thread http://groups.google.com/group/cake-php/browse_thread/thread/ee9456de93d2eece/cff6fe580d13622b?lnk=gst&q=auth
A previous time I caused the issue by attempting to update the Auth user details after updating the user in the database.
I can see I'm somehow removing the user object from the Auth object but I can't understand why I need to delete files in the site to get it back or how the code above removes it - any help would be much appreciated.
Edit
It looks like in the case I mentioned above, the problem was the app_controller.php file which I'd copied into my app/controllers directory. Just having the file with an empty class declaration causes this error - can anyone provide further insight?
Further edit
I've realised I've been a bit silly and the problem was caused by me putting app_controller.php in /app/controllers/app_controller.php when there was already one in /app/app_controller.php - thanks for the input though Andy, it helps me understand a bit more what was happening.
This error is normally thrown when a class instance (in your case an instance of Auth) has been serialised to disk, then re-read/deserialised in another request but the class definition (i.e. Auth) has not been loaded yet, so PHP creates it as an "stdClass" (standard class.)
When you remove your site files, you're removing the session storage (IIRC it's the Cache folder in a CakePHP app) so at the next request, a new session is created from scratch.
It's been a while since I last used CakePHP (I switched to Zend) so I cannot remember if Cake includes files it requires using an __autoload function or not.
On that mailing list post, someone says that you can this $this->Auth->user() in a view, but in the controller, you can use $session->read('Auth.User') to get the user component. Not sure what the difference is, maybe $this->Auth is a view helper, so isn't available in the controller?

Configure Log4Net for NHibernate

This has got to be a lamer question:
In my test project I am attempting to configure log4net. The following method call gives the error.
BasicConfigurator.Configure();
"type name expected but method found"
What am I overlooking?
Thanks,
Nick
Is this a compile time error or runtime error? Do you have a using log4net.Config statement in your class file? Does it still happen if you change it to reference the full class name?
log4net.Config.BasicConfigurator.Configure();
I'm not sure if linking to blog entries is verboten...
If you are trying to log NHibernate stuff, here is what I do:
How to show Log4Net info in NUnit (from NHibernate)
I also have a more basic getting started guide here:
Getting Started with Log4Net
oops.. I was trying to do this in the wrong context. I added the method call to my test project's constructor and we're good.