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

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.

Related

Sanity CMS: Get current user from datastore

I'm trying to fetch the current user in Sanity CMS.
I found this code snippet which demonstrates use of userStore
But I don't understand how I can configure my project to accept this module lookup
import userStore from 'part:#sanity/base/user';
It throws an import error Cannot find module 'part:#sanity/base/user'. Which makes sense as its a non standard node module.
How can I resolve this so the module is found?
Or alternatively anyone know another way to fetch the current user?
Inspecting that #sanity source I can see base/lib/datastores which has a userStore it's just not obvious how to consume this.
So this example hook works and returns the User. Sanity is taking care of the module resolution. It's an IDE error not a runtime error in Sanity.
(╯°□°)╯︵ ┻━┻
Their advice is to ignore these un resolved module warnings for part imports.
"eslintConfig": {
"rules": {
"import/no-unresolved": [2, { "ignore": ["^(all|part):"] }]
}
},

CConsoleApplication.defaultController not defined when creating new migration

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.

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

"Access denied" error on 'rename' call when uploading files in Symfony

I'm working on a Symfony project in a Win7/Apache 2.2/ZendStudio environment and I have some trouble getting my file uploads to work properly.
My goal is to let the user create a new entity which can contain arbitrary many "Documents" (based on the article found at http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html). I have a form type containing one field of type 'collection' (based on the article found at http://symfony.com/doc/current/cookbook/form/form_collections.html). So far so good. Via jQuery I can add arbitrarily many forms as subforms which works fine. But when I submit my form, very often (but not always!) I get the following exception:
Warning: rename(C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityRecruiter.php.507bf02e30df69.85090364,C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityLecture.php): Zugriff verweigert (code: 5) in C:\Programming\Servers\Apache2.2\htdocs\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Proxy\ProxyFactory.php line 194
Zugriff verweigert is German for Access denied. Weirdly, the files seem to get renamed and saved at the right location nevertheless.
Why do I get this exception, does it have something to do with my environment and how can I fix it? I guess this issue is related to Symfony Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5), but not quite sure whether it's the same as it happens in another context. I do also encounter the problem described in this link, though.
Thanks in advance.
I've been running into the same exact issue recently. I don't really have a good sense of why the problem is happening, but the problem is coming from a step in the process where Doctrine is trying to generate proxy classes.
In my config.yml file, under the ORM section of the Doctrine configuration, I changed the value of auto_generate_proxy_classes from %kernel.debug% to false. I've played with it for a while since making the change and haven't been able to reproduce the issue since.
Found this while looking for same answer, it seems to be a windows + Doctrine issue.
Doctrine Ticket with more detailed info
TLDR: Basically the proxy is trying to rename a file that's still being used, works in Linux but not always on windows.
Go to the file that renames the file, then replace it with a windows compatible rename function
private function renameWindowsCompatible($oldfile,$newfile) {
try {
rename($oldfile,$newfile);
} catch(\Exception $e) {
if (copy($oldfile,$newfile)) {
unlink($oldfile);
return TRUE;
}
return FALSE;
}
return TRUE;
}
I learned about proxies and saw that it is used with lazy loading.
I had an entity A with a one to one relationship to B.
B was the problem is the proxies directory
I just had fetch="EAGER" annotation in A entity
/**
#ORM\OneToOne(targetEntity=B::class, fetch="EAGER")
*/
private $b;
Then the B proxy was not generated and no more problem with rename.
Hope this help.

Using yiidocsgenerator extension to generate documentation

I posted in the Yii forum with no luck. I am hoping someone in this community got this extension working because I really need it!
I used the yiic docs check command, and all the models seem to finally pass the check. So, I proceeded to executing this command:
yiic docs C:\path to my site\protected\models
And at first this appears onscreen:
Building.. : MyApplication Class Reference
Version... : 1.1.7
Source URL:
And then this error pops up:
Building model...
PHP Error[2]:include<GxActiveRecord.php>: failed to open stream: No such file or directory in file C:\path-to-my-app\yii\framework\YiiBase.php at line 396
Where, at that line, I have the following code:
include($className.'.php');
I don't understand why it is looking for a class I do not have!! I found it here, but I don't know in what specific folder that class should reside, or better yet why I should have to download it separately when it's not specified in the instructions. Thanks.
Looks like you've generated models from giix which have GxActiveRecord as a base class and the doc parser does not find this base class, usually you've defined this as an import in your application config, so this may be an expected behavior.
You could try importing something like 'ext.giix.components.GxActiveRecord' in every one of your model classes or copy GxActiveRecord into your models directory just for generating the docs.