I have encountered this error
Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in \VBOXSVR\ACACIASOFT\apc\spreadsheet\lib\phpexcel\PHPExcel\Autoloader.php on line 29
My currrent setup is :
Host Machine : Windows 7
: this is where i check out my solution from svn
Virtual Box Guest Machine :
: Windows XP
: where my apache, php, mysql installed.
: I have also added the shared directory on my virtual box so that i will use this as the documentroot location
My dilemma started when i change the documentroot. it bring error on my phpexcel modules but when i changed back the documentroot c:/program files/apache.... copy the project to this directory. this will not bring any error.
The same problem has been nagging me to death for a whole day.
I found out that if you have your own autoloader function previously registered with spl, then you'll have to return false in the event your autoloader fails to load the required class, like this:
spl_autoload_register('my_autoload');
function my_autoload($className)
{
if(file_exists(CLASS_PREFIX.".$className.php"))
{
require_once(CLASS_PREFIX.".$className.php");
}
else
{
return false;
}
}
Looks like you're running some other library with its own autoloader that interferes with the PHPExcel autoloader. The latest SVN code has been modified to prevent this problem.
In the /Classes/PHPExcel/Autoloader.php script itself, change:
public static function Register() {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
to
public static function Register() {
if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
If anyone happens to be on Linux, then this error can be caused by incorrect usage rights.
I had this same issue, but I changed the owner of the 'Shared' folder, and set it to be 'www-data' user, which is the apache user on my system (chown www-data:www-data Shared). This fixed the "Class 'PHPExcel_Shared_ZipStreamWrapper' not found" error.
Yet this is not the full fix, What you really need to do is make sure the folders and files in the PHPExcel folder are assigned to the correct user, and that they have the correct rights. Here is how you do it:
You need to assign the PHPExcel folder and every item in it to the www-data user so Apache can access the files. Make sure you are one level below your PHPExcel folder and then run this command:
sudo chown -R www-data:www-data PHPExcel
And that is that it. Apache should be able to access all the files and the error should be resolved.
You must enable on php extension the zip dll
Ok I know it's already a year ago, but since this problem occured to my setup (Virtual Machine running Windows 7 Professional in an Active Directory network with explicit user rights) just a few days ago i wanted to share my solution, maybe this will help others to save some time:
I figured out 2 problems (only on WINDOWS HOSTS!):
the PHPEXCEL_ROOT-Constant is defined with wrong directory seperators
MY SOLUTION: change the php code to use the DIRECTORY_SEPARATOR constant in the defitinions
in the file: PHPExcel.php (around Line 32) like this:
//OLD: define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
define('PHPEXCEL_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
there are 2 more files to change: "IOFactory.php" and "Settings.php" (Line 34) to:
//OLD: define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
define('PHPEXCEL_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR);
the PHP function "is_readable" does not always return correct results on Windows hosts, in my case the file was readable but the result was false.
MY WORKAROUND: To work around this Bug, you can remove the "is_readable" check in the file "autoload.php" change line 77 to:
// if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
if (file_exists($pClassFilePath) === FALSE) {
Related
Currently I have PHP 7.2 installed and I was trying to get spatie/image-optimizer to work but somehow it considers my literal paths as non existent ones. If I give it the following path:
/data/www/MY DOMAIN/images/thumbnails/700/615/detailed/1/83-221-343-V01.jpg
It will output the following:
2018/07/13 14:44:26 [error] 18931#18931: *3749 FastCGI sent in stderr:
"PHP message: PHP Fatal error: Uncaught InvalidArgumentException:
/data/www/MY DOMAIN/images/thumbnails/700/615/detailed/1/83-221-343-V01.jpg
does not exist in
/data/www/MY DOMAIN/app/addons/theme/lib/vendor/spatie/image-optimizer/src/Image.php:14
But if I check the directory I can confirm that the file is there with the correct permissions.
Any ideas?
I just looked at the Image class on Github. Here's where the exception is thrown.
public function __construct(string $pathToImage)
{
if (! file_exists($pathToImage)) {
throw new InvalidArgumentException("`{$pathToImage}` does not exist");
}
$this->pathToImage = $pathToImage;
}
A good way of checking you have it properly set is to use realpath()
Realpath creates absolute paths from relative ones, returning false if the path doesn't exist.
$path = __DIR__ .'/../../something'; // (imagine __DIR__ is /some/random/path to begin with)
echo $path; // outputs /some/something
You can also check in your terminal simply by typing:
ls /path/to/image.jpg
If it lists, it does indeed exist and shouldn't throw an error.
Switch to the user your php is running as and try to access the file. It could be that you are missing the execute permissions on one of the folders on the way to the file.
Trying to set up a Symfony 3.3 environment with Flex. Currently, when trying to require some packages like the following:
composer req annotations security orm template asset validator
Everything goes well, except on cache:clear I'm getting the following errors:
!! [Symfony\Component\Filesystem\Exception\IOException]
!! Failed to remove directory "/home/vagrant/Code/multi-user-gallery-blog/var/
!! cache/loca~/pools": rmdir(/home/vagrant/Code/multi-user-gallery-blog/var/ca
!! che/loca~/pools): Directory not empty.
I already tried to remove the folders manually, but those are generated automatically in the installation process, and then Symfony cannot remove them.
I'm running this on Vagrant Homestead.
Any idea on how can I solve this problem?
This is an issue with the way Vagrant/VirtualBox maps shared folders between the host and guest machines. In Symfony projects, the cache directory is typically placed within the project directory that gets synced from the host machine.
We can change the cache directory to use a location within the guest machine's filesystem to avoid these problems by adding an override method to the app/AppKernel.php class:
class AppKernel extends Kernel
{
...
public function getCacheDir()
{
if ($this->environment === 'local') {
return '/tmp/symfony/cache';
}
return parent::getCacheDir();
}
}
The example above demonstrates how we can set a custom cache directory for local development environments while retaining the default behavior for production. /tmp/symfony/cache is just an example. We can choose a location anywhere on the guest machine's filesystem that the application has permission to write to. Replace 'local' with the name of the environment the project uses for development.
See my comment to the accepted answer, here is the code:
public function getCacheDir()
{
if (in_array($this->environment, ['dev', 'test'])) {
return '/tmp/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, ['dev', 'test'])) {
return '/var/log/symfony/logs';
}
return parent::getLogDir();
}
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 am getting the error:
PHP Fatal error: Class 'Symfony\\Component\\Process\\PhpProcess' not found in ...
It's my first time using Symfony. I download the files from the GitHub site. Since the downloaded files are of the Process directory, I created folders in order to have the correct path. (Symfony/Component/Process/DOWNLOADED FILES).
I placed the Symfony directory in the main directory (where my index file is).
Is this how you install Symfony? (Note I only need the Process sub-directory and not the whole framework)
For now I am using this ready-made code, just to see if I can get it running:
use Symfony\Component\Process\PhpProcess;
$command = file_get_contents('/hello_world.php');
if ( $command ) {
$process = new PhpProcess($command); //<----- GETTING ERROR HERE
$process->run();
if ($process->isSuccessful()) {
$output = $process->getOutput();
// ...
}
else {
throw new Exception($process->getErrorOutput());
}
}
Why am I getting this error and how can I fix it please? Is it due to a bad path?
I think it has to do with namespace registration, have you checked that the namespace that defines the class is loaded?, check the ClassLoader reference
Check the autoload.php file inside your app directory
I am trying to install xml diff ; https://github.com/mmacia/XMLdiff and i have not managed yet to make it work.Whenever i run any test example,i get
Fatal error: Interface 'PHPUnit_Framework_Test' not found in
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php on line 85
Has anyone managed to install and use the library.I am using xampp on windows.
I believe your problem has to do with PHPUnit's Autoloader.php not being included. This file sets the php spl_autoloadspl_register function which is responsible for loading in interfaces and classes like PHPUnit_Framework_Test.
According to this SO question, you have to include the autoloader file manually. Without knowing more about your set-up and how that particular library works, I would say do something like this in the appropriate file(s):
// define phpunit path
if ( ! defined('PHPUNIT_PATH')) {
// define an absolute path to your PHPUnit dir
// CHECK THIS, i'm not good with php on windows:
define('PHPUNIT_PATH','C:\xampp\php\PEAR\PHPUnit');
}
// Then include the autoloader like this:
include PHPUNIT_PATH.'Autoloader.php';
I hope this helps you or anyone else out.
Check execution flags for C:\xampp\php\PEAR\PHPUnit\Framework\Framework\Test.php
The file needs to be executable by the user who is launching tests (probably you).