I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
Problem solved.
The old framework was using the old __autoload function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload to spl_autoload_register.
Similar Question: Override vendor autoload composer
I'm new to php and i'm using log4php with laravel.
My project structure is
->Root
->Laravel
->app
->folderx
->abc.php
->otherfolders
.
.
->vendor
->composer.json (contains log4php and laravel)
->logconfig.xml
I'm trying to initialize the logger from inside abc.php,
Logger::configure('../../../logconfig.xml');
but it gives the error message
Class 'Apache\Log4php\Hierarchy' not found
I verified that the class Hierarchy.php exists in the vendor/apache/log4php/src under Root folder. Also, if I open Logger.php and go to the line where Hierarchy in initialized and ctrl+click(in eclipse) on Hierarchy, it takes me to Hierarchy.php.
I'm trying to figure out why php is not able to find that class.
Any help/suggestions would be greatly appreciated.
Thanks
That error message shows that your PHP is looking for a namespaced class. Log4PHP has never been released until now with namespaces (up to version 2.3.0), so this is definitely weird.
If you accidentially use the development branch of the 3.0 version, I must currently suggest not to use it. It barely got any significant commits in the last year, and should be considered work in progress (very slow progress unfortunately).
i am trying to run basic example of phpExcel in symfony1.4 and i am getting this error
C:\wamp\www\orangehrm-3.01\symfony>php plugins/sfPhpExcelPlugin/examples_1_2/01s
imple.php
10:39:01 Create new PHPExcel object
PHP Fatal error: Class 'sfConfig' not found in C:\wamp\www\orangehrm-3.01\symfo
ny\plugins\sfPhpExcelPlugin\lib\sfPhpExcel.class.php on line 9
any idea will be approciate.
The code for this plugin's examples is a bit strange. It uses the sfConfig class to read Symfony config variables but doesn't initialize nor include any Symfony code (hence the error).
In fact when you look at the code of this plugin you'll see that all it does is set some configuration when instantiating PHPExcel object. I would skip the plugin altogether and just use the PHPExcel directly in your project (you can either include it in the controller where you use it or in the ProjectConfiguration.class.php to make it available for the whole project (not recommended though).
I've created a phar of a Symfony2 web application, but I'm having some troubles with the cache-folders.
I found out that I could mount an external file/folder into a phar. That would fix my issue, but I can't get the example on the PHP site working.
I have a phar which contains an index.php:
<?php
$configuration = simplexml_load_string(file_get_contents(
Phar::running(false) . '/config.xml'));
?>
Then I include the .phar with the following code:
<?php
// first set up the association between the abstract config.xml
// and the actual one on disk
Phar::mount('phar://config.xml', '/var/www/$projectname/config.xml');
// now run the application
include 'phar-archive.phar';
?>
All files exists, but I get the following error:
PHP Fatal error: Uncaught exception 'PharException' with message 'config.xml is not a phar archive, cannot mount' in /var/www/$projectname/index.php:3
I already tried relative/absolute paths, changing permissions but can't get this to work. Additionally a working example of how I could mount a folder into a phar would be great !
First check that variable $projectname exist in this place (just run echo $projectname; before Phar::mount). If all ok, then change
Phar::mount('phar://config.xml', '/var/www/$projectname/config.xml');
to
Phar::mount('phar://config.xml', "/var/www/{$projectname}/config.xml");
It seems that variable $projectname not converted to its value because you used single quotes.
I'm using PHP 5.4, and have a PSR-0 class structure similar to the following.
A\Library\Session.php:
namespace A\Library;
class Session { ... }
My\Application\Session.php:
namespace My\Application;
class Session { ... }
My\Application\Facebook.php:
namespace My\Application;
use A\Library\Session;
class Facebook { ... }
When I try to run the application, I get the following error:
Cannot use A\Library\Session as Session because the name is already in use in My\Application\Facebook.php
Even though it's not, at least not in this file. The Facebook.php file declares only the Facebook class, and imports exactly one Session class, the A\Library one.
The only problem I can see is that another Session class exists in the same namespace as the Facebook class, but as it was never imported in the Facebook.php file, I thought it did not matter at all.
Am I wrong (in that case please point to the relevant documentation), or is this a bug?
There is a bug confirmed in PHP that may affect the behavior you see. It is supposed to fatal error, but with opcache enabled, it may still execute flawlessly.
https://bugs.php.net/bug.php?id=66773
If it still concerns you, please vote for the bug.
No, this is not a bug. As mentioned in Using namespaces: Aliasing/Importing
use A\Library\Session;
is the same as:
use A\Library\Session as Session;
So try using something like:
use A\Library\Session as AnotherSessionClassName;
The only problem I can see is that another Session class exists in the
same namespace as the Facebook class, but as it was never imported in
the Facebook.php file, I thought it did not matter at all.
Yes, it does matter. This is why you don't need to "import" classes from the same namespace. If you have conflicting names from different namespaces, you need to alias the class.
namespace My\Application;
use A\Library\Session as ASession; // choose a proper alias name here
class Facebook { ... }
I've read the thread about the issue, but I tested on many PHP versions (php 5.5, 5.6, 7.*, x32, x64, vc11, vc14, vc5). I'm using Laravel with Laragon. But, when I build up the server with php artisan serve (and open the server at http://localhost:8000) I have the problem of "the namespace that some Class was already used" and stuff.
I tested with and without opcache extension and nothing works, then I tested the virtual domain that Laragon provides and... voila, the error just disappeared and now I can work OK. I don't know what was happening, my namespaces were OK, I had an alias but the same code works in many machine without problem (AWS, local, prod, dev, etc) but only in my machine I had the problem just as I described it.
So, if someone is working with Laravel (5.1) and is having this issue, try the virtual host of Laragon.