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.
Related
I am a newbie with phpunit but I need it to test something
So, suppose that have the following folders
mainFolder/SRC/x/y/sourceFiles.php
mainFolder/TESTS/x/y/testFiles.php
mainFolder/TESTS/bootstrap.php
When I run phpunit mainFolder it tells me:
Fatal error: Class 'x/y/sourceFile' not found in mainfolder/tests/x/y/testfile.php on line 28
Note that I am a newbie, and I need some help.
Thanks
The test files should be able to find the tested classes. Which means you have to require them, or set up a proper autoloading mechanism or pre-load them in a bootstrap file. And probably there are lots of other ways to do this. The test files behave exactly the same in this sense like simple php files.
Good day everyone.
I am frontend developer but I have to make slight adjustments in the backend, built with Zend Framework.
I have a controller CalendarController.php, and wanted to make a relative model, called Calendar. The model was instantiated as
`class Project_Model_Calendar extends Project_Model_Abstract`
in a file called Calendar, placed in Model directory.
Later on I figured out that I dont need this model, so I simply deleted it, along with only reference to it in the controller. (it was used like this
`$this->form = new Project_Model_Calendar();`
)
Apparently there is some memory cache or config file that saved this model, and tries to load it every time.
I get the following error
Zend_Session::start() Error #2 include_once() [function.include]: Failed opening 'Project/Model/Calendar.php' for inclusion
Why do I get this error if I dont use the model anywhere? How can I clear this cache of loaded models?
Could you please help me with it? Please forgive me for asking such unspecific questions, but I need to fix it, and Zend framework is still a mystry for me most of the time.
Including the file will probably still result in an error, even if you're not using it. Make sure it isn't hardcode included in the paths in your php.ini, httpd.conf, or .htaccess files.
I have a problem where I would like assistence with.
Currently on working on a new project for myself and I am trying to start with a good foundation.
I have build the following file structure (relavant part):
Class/
Class/class.filename.php
Class/class.etc.php
Func/
Func/func.filename.php
Func/func.etc.php
Config/config.php
index.php
In my config file all classes and functions are included with the require_once function (I loop alle files and directories inside func and class). In the folder class the file for firePHP is located which I include and then setup in the config.php.
In my config.php and index.php I can call this log function perfectly, but when I use it in one of the func.filename.php or class.filename.php it errors. The child (func/class) is not seeing the other included functions within config.php.
Hope somebody can help me out with this.
You func.filename.php file needs to "require_once" the file that contains the log function.
Another solution that may work for you (since you have this structure) is to have all your required files in config.php (included with require_once(<file>)). This seems to work. Then, when other files required any other function for other files, just require_once('config.php').
It is best to only include what you need, when you need it. Why spend the time loading 50 different classes/functions/snippets when you might only need 2 or 3 for the script at hand? Paring out unnecessary include statements can increase the performance of your scripts considerably.
Make use of the __autoload() function for classes. It is just super.
Chain include_once() or require_once() through your various files so that grabbing one file that you need for a given job automatically gets its own dependencies.
I am using and have been using the framework CodeIgniter for a while. It works perfectly on my localhost, once I upload it to a server it gives the following error message
Unable to locate the model you have specified: auth_model
To point it out, it works on my apache perfectly, do you have any idea to what the problem can be? I am talking with customer support of the webbhotel, but they can't seem to find anything on their end.
Thanks in advance.
Edit: It manages to load many different files, the session library, my own controllers, helpers and view files. It just models that it stops at, I've named them all 'Auth_model.php", 'Login_model.php' etc. The models themselves are declared class Auth_model extends CI_Model {}
Sounds like a path issue,
I would first check where your starting at and get some data to compare with
CodeIgniter FCPATH and APPATH are both set in the main index.php file,
FCPATH = root
APPATH = application folder
Find out what your paths are set to, check your config/config.php file make sure you have correct info there.
Just a thought, are you using a common auth library? Sucb as freak/ion/bit/etc auth's
The session error, is being caused by echoing data you can google the error and get a decent understanding of the error from there.
As it turns out the webhotel (one.com) got a delay when you upload, hence it was a bit troublesome to actually troubleshoot it, but here it goes. Every file name except for the exception of MY_Controller needs to be in lower cases. So the answer was pointed out by some people.
The problem is with codeigniter because it looks for lower cases only in some cases. So yeah, models should be in lower cases from now on!
When I try to generate a CRUD test for a new project I am getting a PHP Warning and a Fatal Error.
The errors relate to files that it cannot find, however, I have checked and the files are definitely there.
The error text is 'require_once(lib/model/map/QuestionMapBuilder.php): failed to open stream: No such file or directory in c:\webroot\askeet\lib\model\om\BaseQuestionPeer.php on line 547'
What details of my project should I check?
I think it's a problem with your include path.
Check it, the require_once() call is looking for lib/model/map/QuestionMapBuilder.php
But your include_path is C:\webroot\askeet\lib
Which, when resolved together into a full path, would look like this
C:\webroot\askeet\lib\lib\model\map\QuestionMapBuilder.php
So, I think your solution is to add C:\webroot\askeet to your include path.
You are generating crud for the Question model class but it doesn't seem to exist. Documentation on using the crud generator
First you must use the schema.yml file to define your database, and run
./symfony propel:build-model
to generate your model files. (this will generate lib\model\map\QuestionMapBuilder.php)
I finally tracked down the issue. In my PHP.ini files, they were setup wit the default UNIX file path settings.
Weirdly nothing had ever been broken by this incorrect configuration. Plus, everything in Symfony had worked up until now.
I have switched to Windows style file_path and all is well again.
Thanks for all the answers!