I use __autoload to load classes, and I keep getting errors that no class is found but file get's loaded ok.
Then if I change something in a file, just something like add a new line and save it, everything works fine and class is then found.
But this is a great problem cause there are thousands of files in this project and I don't want to change them one by one.
I'm using php 5.3.0 on windows.
What could be the problem?
I found that the problem is only with php version 5.3.0 and corresponding php_apc.dll
Related
I'm working on a project with protocol buffers and after i compiled a proto file, i cant seem to include it neither run it cos it keeps giving me this exact error:
PHP Fatal error: Class 'Google\Protobuf\Internal\Message' not found in /app/generated_files/message.php on line 13
On message.php i have the auto generated file from a .proto file and it includes Google\Protobuf\Internal\Message.
While reading on the protobuf github issues, i found that a person had the same problem where he concluded that it was the composer's fault. However in my case that wouldnt be the issue cos i didnt use composer.
I used pecl to install protocol buffers, and i have the library protobuf.so located in /etc/php5/apache2/XXXXXXXXX. I also added extension=protobuf.so on the last line of php.ini.
Keep in mind that im using docker for everything, therefore it might be something different but i still doubt.
In case anyone ends up here with the same question: you just need to add componser autoloader to your file include_once './vendor/autoload.php'; (change path as required)
I had the same problem, but the reason was different for me:
Git somehow messed up the casing of the folders, which lead to a wrong file path translation.
As soon as I fixed the casing ([...]/src/Google/Protobuf instead of [...]/src/google/protobuf in the vendor folder)
I wish to use TCPDF so have downloaded the code and am having trouble using it.
I work on Mac locally using MAMP.
My project is stored in:
/Applications/MAMP/htdocs/my-project-title
I place the whole tcpdf folder in my project so it's location is:
/Applications/MAMP/htdocs/my-project-title/tcpdf
I found a file tcpdf_include.php in the examples directory so I pulled it out and placed it also in the tcpdf folder:
/Applications/MAMP/htdocs/my-project-title/tcpdf/tcpdf_include.php
So I wasn't sure if this was right but it seemed so. I then referenced tcpdf_include.php in my script: require_once('../tcpdf/tcpdf_include.php'); and it found the file all good.
Now I was confused as to how exactly this was working. I ran an example and got nothing and error log states:
[04-Nov-2015 16:27:36 Europe/Berlin] PHP Fatal error: Class 'TCPDF' not found in /Applications/MAMP/htdocs/my-project-title/scripts/myscript.php on line 15
... so it seems like it's just not running the script. I went to the config file to attempt to edit some stuff there.
I changed the following in the config file:
define ('K_PATH_MAIN', '/MAMP/htdocs/my-project-title/tcpdf/');
define ('K_PATH_URL', 'http://localhost:8888/my-project-title/tcpdf/');
These are now inline with how my project is set up. But I'm still getting the above error when I try to run the script.
What am I missing are there any examples of how to properly configure TCPDF?
Try this:
Store the script you are trying to run in /Applications/MAMP/htdocs/my-project-title, eg. /Applications/MAMP/htdocs/my-project-title/test.php
In that script, just do require_once('tcpdf/tcpdf.php'); (I'm assuming the tcpdf folder is still sitting here: /Applications/MAMP/htdocs/my-project-title/tcpdf)
You should then be able to instantiate an instance of the TCPDF class.
You shouldn't need to worry about anything else - it should just work. If it doesn't, try creating a fresh folder in your htdocs folder, drop a fresh copy of tcpdf in there and try again, just in case you've moved something in your current version that is messing things up.
To be clear, this is what test.php should contain:
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF();
Good luck!
In my PHP app, I have several calls to require_once. On my development PC this works fine and doesn't try to include the same file multiple times. However when I moved it to my production server I'm getting an error
cannot redeclare class myClass
After searching through the code I've found that this happens just after a call to require_once, so it must be that which is causing it.
I've searched through the entire project and this class is definitely only declared in one file, and it's only ever included through require_once. Is there some weird PHP config that would make require_once behave differently on the production server?
Thanks
Put the following at the top of your included class file:
if( class_exists( "<yourclassname>"))
{
throw new Exception("Class already defined");
}
You will now receive a clear error message where the class is re-called.
OK, this obnoxious problem can be caused by one of two things of which I'm aware:
symlinks; if loading from a file and a symlink pointing to the file
on OS X (and maybe Windows), the filenames are case-insensitive; PHP require_once is not
This had me confused for several hours today. I usually work in Linux, but I was forced onto a Mac where this becomes a problem.
I would like to include a PHP program into a Joomla! article, this program calls different PHP files that are used to display what I want, I have tried to install different Plugins such as Jumi, directPHP and others, but I keep getting the following error:
Application raised an exception class EDatabaseError with message 'Cannot connect to database server:mysql error: [0: Connection error to server '' with user ''] in CONNECT(, '', '**', )
'
The program runs fine Standalone, however it does not work when I'm running it on Joomla.
The connection parameters are obtained from an include "config.php" but it seems that they won't get the includes from the included PHP file.
Also when I try to include a menu I have made, which works standalone, redirects me to the index.php of Joomla! root dir.
Thanks.
I've done things similar to this, but have had to install a couple of extensions to get them to work.
First, i use the jce WYSIWYG.
then installed place anywhere (which lets you place modules inside articles)
create a new module, type=Custom HTML
code your php there...
I know this isn't exactly what you're describing, but it's the closest i've come in my experience.
If it doesn't work right away, be sure to check for the settings withing the JCE WYSIWYG so it's not breaking your php.
hope this helps!
Try to use 'Flexi Custom Code' extension is a good one
check it: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/15251
Its a module extension which you can use with 'module anywhere' to place in the 'content area'(article). For calling different php file you can use the php include or required once code
Please feel free to ask if any doubts are there....implementing this
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!