I'm trying to manually install PhpPowerpoint (not using composer)
I've WAMP installation having document_root D:\wamp\www\
i've copied the PhpPowerpoint folder under the following path D:\wamp\www\php\PhpOffice\
using the manual installation code (the code is in a file D:\wamp\www\php\agile\expMSPowerpoint.php):
require_once '../PhpOffice/PhpPowerpoint/Autoloader.php';
PhpOffice\PhpPowerpoint\Autoloader::register();
$objPHPPowerPoint = new PhpPowerpoint(); <<<< Error in this line
i get the error:
Fatal error: Class 'PhpPowerpoint' not found in D:\wamp\www\php\agile\expMSPowerpoint.php on line 435
Any help to get it installed would be much appreciated
I suggest using the PHP realpath http://php.net/manual/en/function.realpath.php
From the manual page:
realpath() expands all symbolic links and resolves references to
'/./', '/../' and extra '/' characters in the input path and returns
the canonicalized absolute pathname.
Related
Run dev_appserver.py and now get an error relating to curl.so:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\dev\google-cloud-sdk\platform\google_appengine\php\php-5.5-Win32-VC11-x86\curl.so' - The specified module could not be found.
This file does appear to be missing from the directory specified but haven't touched anything and have not had this error before.
How do I resolve?
Additional info
I have found there is already a php.ini file in same directory as app.yaml, just a few basic lines:
extension = "curl.so"
;extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
So I changed it to comment out the first line and restore the second line:
;extension = "curl.so"
extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
The error now changes to cant find ...php_curl.dll.
Yet the file seems to be there:
So why the error now? seems the path to dll is correct.
If you want to use Curl and not Curl Lite, then you need to reference the .dll version while using a Windows based system. Create a php.ini file in the same directory as your app.yaml file add the following line to it:
extension = php_curl.dll
If instead you want to use curl lite, you can remove the line above and instead add:
google_app_engine.enable_curl_lite = "1"
to the php.ini file.
I have PHPUnit set up in my PHPStorm project. I've referenced the PHPUnit phar file and have a PHP executable linked to my PHPStorm run configuration. My directory structure looks like:
/lib/classes/Class.php
/lib/vendor/phpunit.phar
/lib/test/ClassTest.php
In my ClassTest.php file, I reference the other two files with:
require_once (__DIR__ . "../vendor/phpunit.phar");
require_once (__DIR__ . "../classes/Class.php");
I get the following error when I run my test:
Fatal error: require_once(): Failed opening required
'C:\Users\me\PhpstormProjects\myproject\lib\tests../vendor/phpunit.phar'
It seems like the PHP parser isn't correctly parsing the up one directory ../ command.
Why is this happening?
First of all: this line is not needed (at all) as PHPUnit will already be loaded at that time.
require_once (__DIR__ . "../vendor/phpunit.phar");
Secondly: __DIR__ constant in PHP does not contain trailing slash. When used in require/include statements (and other places when building full file path) you have to add it yourself.
In your particular case it has to be (note / before ..):
require_once (__DIR__ . "/../classes/Class.php");
I am working on ubuntu 12.04. I installed HTTP_Client by sudo pear install HTTP_Client. But when I am using require_once 'HTTP/Client.php';. It's showing:
Warning: require_once(HTTP/Client.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /var/www/mai.php on line 3
How I remove this error?
How paths are resolved when using include or require is controlled by the include_path php.ini setting, which is typically set to:
include_path=".:/usr/share/php"
Whereby /usr/share/php points to where PEAR is installed.
It can be set using set_include_path() during runtime as well:
set_include_path(".:/usr/share/php");
Should be run before you include anything else.
'HTTP/Client.php' is a relative path. The error message means that the file doesn't exist at that location. You'll need to modify the path, or move the file.
In this case your PHP file is in "/var/www/" and there is no HTTP directory there.
Edit: I would recommend modifying the path to be the full path rather than the relative path:
require_once 'HTTP/Client.php';
Change to:
require_once '/usr/share/php/HTTP/Client.php';
I get those errors when i run phpcs (the PHP_CodeSniffer pear package) (which i need to use PAReview.sh) on my MAC
PHP Deprecated: Assigning the return value of new by reference is deprecated in usr/lib/php/PEAR/Frontend.php on line 91 PHP Fatal
error: Class 'PEAR' not found in /usr/lib/php/PEAR/Frontend.php on
line 47
The basically on line 47 the PEAR class is extended. The strange thing is that i have the PEAR class here
/usr/lib/php/PEAR.php
/usr/local/zend/share/pear/PEAR.php
but this is in my include path
include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/usr/lib/php'
What is worng?
My guess is that your include_path has a file named PEAR.php (case in-sensitive on Mac), which does not contain the class PEAR definition. I'd look through each of the directories in your include_path and see if there's another file that it is pulling in before the correct PEAR.php file (make sure you look in the current working directory as well, because you have . in your path).
I get this error on my production server (CentOS 5.4 and php 5.3.5) :
Warning: include_once(PharData.php): failed to open stream: No such
file or directory in /var/www/ZendFramework/library/Zend/Loader.php on
line 146
Warning: include_once(): Failed opening 'PharData.php' for inclusion
(include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php')
in /var/www/ZendFw/library/Zend/Loader.php on line 146
Fatal error: Class 'PharData' not found in
/var/www/vm/app/Backup.php on line 40
And this is the code which fail :
$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");
This code is working fine on my own computer.
PharData should be included by default in php 5.3+ ...
Thanks for your help!
UPDATE :
I am using the Zend Auto loader feature to load the good php files using this code :
require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
Zend autoloader is doing the include_once(PharData.php).
Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.
To confirm this, run the following script:
<?php
phpinfo();
?>
One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.
If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).