I'm struggling to get the Yii crud tool to work for me. I'm using Gii and this is the error I'm getting in my log file:
PHP Fatal error: Cannot redeclare class CController in /var/www/includes/framework/web/CController.php on line 77
These are the only steps I have taken:
1) Downloaded yii and extracted 'framework' into /var/www/includes
1.5) Created a table called me in my database [EDIT]
2) Executed /var/www/framework/yiic webapp /var/www/web
3) uncommented 'gii'=>array(....) in config/main.php
3.5) Added my database configurations [EDIT]
4) Browsed to http:///index.php?r=gii
5) Navigated through Model generator to create 'me'
6) Navigated through Crud generator using me
7) Browsed to http:///index.php?r=me
Any ideas? I've spent ages on this and now I'm rather annoyed. :(
Thanks for your help in advance.
It looks like you have the framework in /var/www/framework/ AND /var/www/includes/framework/. Thus it is being included twice and you get an error that you are declaring the class twice. Remove the second copy from the /includes folder and stick with the one in /www. It's also best practice to make sure your framework folder is not accessible from the web.
I'm not sure why this worked but it did.
I simply renamed the framework directory to yii and it worked. I did nothing else.
This has confused me but at least it now works.
Related
I am working on a project, that I have inherited from several previous teams, thus all the ins and outs of all the workings is beyond my knowledge. But I'm trying to implement a new class EmailListener and it is in the file EmailListener.php under ../protected/controllers. When Try to call this class I get an error
include(EmailListener.php): failed to open stream: No such file or directory
from within yiiBase autoload line 421
else
421 include($className.'.php'); //this line
I have looked around extensively and the only suggestion is to check for case sensitivity. Which I have, multiple times. To the extent of copying the entire path into the class name and deleting everything around "EmailListener" to ensure that there are no typos that I am not seeing. I have also tried different manual includes of my file before the command is run to call it and that just crashes the whole website. Are there any other things I could be doing wrong? Is there any other code I can present?
Thank you for any help, I'm pulling my hair out.
First off, the protected/controllers directory should only be used for controllers. Extra classes you create for other things generally go in protected/components.
Your protected/config/main.php (and protected/config/console.php if you're doing console stuff) should have an import section. By default, one of the things imported is "application.components.*". If that's the case, than any class you put in protected/components will auto-load when you ask for it.
I am trying to get PHPUnit (for TDD) working with CodeIgniter.
A perfectly reasonable guide that I am following is here: http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
But the problem I am getting is this:
c:\projects\project1\tests>phpunit .
Fatal error: Call to undefined function get_instance() in c:\....\PostTest.php on line 7
which almost sounds like my whole CodeIgniter framework is not being seen.
I've modified the bootstrap.php file to have an explicit path to the system and application folders, just to be sure that it's not something simple like that. But no luck.
What does get_instance depend on to run? It's part of the core CodeIgniter framework.
I got the same error.
The problem is in the file phpunit.xml
You need to place it on
c:\projects\project1\tests>
and you need to create the file bootstrap.php as on your link :
http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
that's how your tests connect to your codeigniter
I've created a custom banner module for Magento and I've tested it locally on my Vagrant/VirtualBox setup running an instance of precise32 and everything is working great.
When I pulled the code from GitHub on to a staging server the extension is not working and I'm getting the following error:
PHP Fatal error: Call to a member function getCollection() on a non-object in /var/colourbox/app/code/local/AffinityCloud/ACBanners/Block/Slider.php on line 7, referer: http://colourbox.affinitycloud.co.uk/tub-storage.html
This is while viewing the home page, so I'm not sure why it's referencing http://colourbox.affinitycloud.co.uk/tub-storage.html as the referer as this is a category page.
I've cleared the cache (is disabled anyway) and reindexed. Stil no joy. I've also tried to rename the model classes using lowercase characters and the first character uppercase with no result.
I've added the module code to GitHub below so you can see the code:
https://github.com/garethdaine/acbanners
Any ideas why this would be working locally and not on the staging server? It's as if it can't find the model classes but has no problem fining the Slider.php class.
I'm at a loss as to what to do here.
NOTE: For brevity, I would like to add that I have logged out and back in to the admin, while also deleting the module tables and the reference in core_resource to no avail. It creates the tables fine but I still get the same issues and the module is showing as enabled in the advanced config.
The problem is case sensitivity.
On windows systems the file names are not case sensitive. On Unix they are case sensitive.
So in the ways you configured the module and named the files, when calling Mage::getModel('acbanners/acbanners') the magento autoloader looks for the file
AffinityCloud/ACBanners/Model/Acbanners.php But the real name of your file is AffinityCloud/ACBanners/Model/ACBanners.php
So the file is not found and the class is not loaded and Mage::getModel(...) returns null.
You have 2 options here.
The cleanest and fastest. rename all your classes in the Model folder to start with a capital letter and the rest should be lowercase. Acbanners.php in the example above. You may need to do the same for the files in Block and Helper.
The long version. If you want to keep the file names you need to change Mage::getModel('acbanners/acbanners') to Mage::getModel('acbanners/aCBanners') or Mage::getModel('acbanners/ACBanners'). but I guess this will take a lot of refactoring. You may also need this for blocks and helpers also.
Before you answer let me explain. It works fine with local projects LOCALLY but not over FTP even with PHP class files are in the same directory.
For example if I have a file I'm including using require 'happyclass.php'; in my index.php file and I want to use a class that's in happyclass called happy I can do something like
$happy = new happy();
it will suggest the class and also autocompelte and auto-show PUBLIC METHODS AND FIELDS ETC OF THAT CLASS!
So for example say there was a public method called beHappy() in the happy class then when I did this
$happy->
The problem would still auto-show beHappy() as a public method of that class and suggest it. All I have to do is press enter.
This works fine locally but NOT IF I'M USING THE CONNECTIONS MANAGER for FTP built into aptana. My workaround has been using synchronization from local to remote but this is annoying and seems unnecessary.
What can I do? Thanks for the help guys!
That how I get it to work:
create new project make sure PHP.
Right click on project icon.
PHP Buildpath - click add and choose folder witch all your classes.
OK
Bit lower Project Natures makes sure PHP is Primary;
OK
sometimes restart Aptana 3 and autocomplete working fine;
Greetings,
I've encountered a seemingly bizarre issue, and was wondering if anyone is able to shed a light.
I created a simple controller two levels down from the traditional /application/controllers/ directory and I'm seeing a CI-generated 404 when hitting said controller.
To elaborate, my directory structure is as follows:
/ci/application/controllers/dir1/dir2/myfile.php
The file itself has a simple function with an echo statement. When I move said file up one level such that it is located in:
/ci/application/controllers/dir1/myfile.php
It works.
I've tried changing the name of the "dir2" directory in the example above, the name of the controller, the names of the functions within the controller -- to no avail. I'm able to hit the same php file without going through the Code Igniter framework, and I'm on a Windows machine working normally so I can't imagine this to be a permissions-related issue.
I'm led to think that CI simply isn't willing to go into the controllers directory more than one level. Is this possible, or am I missing something?
Try this out: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/
Basically, you need to override the default codeigniter router with your own MY_Router class
"Out of the box", Codeigniter only supports a single level directory structure for Controllers.
There are ways to extend the default Router class to enable this feature.