ZipArchive not installed in xampp? - php

I have newest version of XAMPP and php version 5.6.3, but I can't use ZipArchive. I've downloaded php_zip.dll and placed it in ext dir, I've added extension=php_zip.dll but after server reset I have warming :
"Module 'zip' already loaded"
I still see error: ZipArchive not found ...
using:
$zip = new ZipArchive();
returns error:
Fatal error: Class 'Att\Controller\ZipArchive' not found in ...

OK, given the additional information you added upon my suggestion in the comment things become more clear now. This looks like you have a namespacing issue here: php tries to locate the class Att\Controller\ZipArchive, not the class ZipArchive. This is probably the case because you try to use the class inside a namespaced script. In that case php will assume all class names as local to the general namespace as declared at the beginning of the script unless they are noted with a specific namespace reference.
Try makeing the class name to reference the global namespace explicitly. So instead of
$zip = new ZipArchive();
do this:
$zip = new \ZipArchive;
(Note the back slash (\) before the class name. Also you can drop the empty brackets trailing it, since they are empty.)
Now php will try to locate a class called "ZipArchive" in the global namespace (\) and (hopefully) succeed... This is a general effect of namespacing in php and has nothing to do with the specific class you are trying to use.
You may want to read a bit about php and namespaces. Take a look into the documentation: http://php.net/manual/en/language.namespaces.php

stop the xampp and then kindly remove the starting semicolon ( ; ) before ;extension=zip from your xampp/php/php.ini the following code, and start xammp again .

Related

Getting error that actually not an error in vscode while using intelephense

Getting unexpected error (Expected 1 arguments. Found 0) in vscode while using intelephense extension.
When I uninstall the intelephense extesion from vscode at that time this error not showing but i dont want to uninstall the extension.
how can i solve this issue??
Error starts showing when i write __construct method in (2.php) file.
Error:
Use namespaces as Brombeer suggests in the comment he made to your question, he deserves credit for this.
I define it based off of the class that the file contains, so I have a class named Animal, and keep the namespace within the Animal class:
<?php
namespace Animal;
class Animal ...
The error exists because the IDE thinks the class you're extending exists as it's using the global namespace
why it's in the global namespace:
https://www.php.net/manual/en/language.namespaces.global.php
namespaces:
https://www.php.net/manual/en/language.namespaces.definition.php
edit: forgetting to add code blocks to comment...

Class not found after "require_once"

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

Use PDFlib in Laravel

I installed PDFlib (followed the instructions PDFlib in PHP How To) on OS X by adding extension=php_pdflib.so to my php.ini file and it is loaded properly.
(If I run phpinfo(); PDFlib is shown in the list.)
However if I try to use it with
$p = new PDFlib();
I get Parse error: syntax error, unexpected '$p' (T_VARIABLE)
What could cause this error?
EDIT
The error was simply caused by a missing semicolon...
Now I am getting a Class 'App\Http\Controllers\PDFlib' not found which is kind of obvious cause I didn't register it in the controller with use.
I thought new PDFlib() is available for global use after installing?
You're missing out the concept of namespaces. In this casePDFlib is available on the global namespace, which is \. In other words, you can either import it with use PDFlib;, or you can use it directly w/o importing it like this $p = new \PDFlib();.
now i am getting a Class 'App\Http\Controllers\PDFlib' not found.
I pretty much doubt you got PDFlib in your Controllers folder therefore it seems that your code that uses PDFlib simply lacks use to refer proper PDFlib's namespace (or you need to use fully qualified namespaces instead).
If PDFlib is not using namespace then from namespaced code youneed to use \ to reach it, i.e.:
$x = new \PDFlib();

Fatal error: Class 'Stripe' not found in C:\wamp\www\

I'm getting an error that class is not found, but I clearly have the right path for where it is located:
<?php
require_once('stripe-php-2.1.0/stripe/lib/Stripe.php');
Stripe::setApiKey('my_key');
var_dump($_POST['stripe-token']);
?>
Every article I've come across all claim that the problem is (not including the right path) in the require_one, include, or require. (I've tried all 3). But still no luck. My database calls follow the same format and my WAMP server has no problem creating my database class.
This is copied directly from my file explore (copy paste)
website\stripe-php-2.1.0\stripe\lib\Stripe.php
My php file that I am using to try and access Stripe sits in the same place as 'website'.
PHP version 5.5.12
tutorial references: http://www.larryullman.com/2013/01/09/writing-the-php-code-to-process-payments-with-stripe/
Other reference: http://www.youtube.com/watch?v=Lka_JBM9bbY
It's because it uses a namespace. Try:
\Stripe\Stripe::setApiKey('my_key');
It is better to initialize all classes.
require_once ("stripe_folder/init.php");
then use namespaces:
\Stripe\Stripe::setApiKey('key_key_key_key_key_key');

Composer, class not found

I installed composer in my CodeIgniter project, downloaded 2 packages: Aura/Sql and Aura/SqlQuery
this is my code from index.php file
require_once ROOTPATH . 'vendor/autoload.php';
use Aura\Sql\ExtendedPdo;
$db = new ExtendedPdo('mysql:host=127.0.0.1;dbname=mydb', 'root', '', array(), array());
var_dump($db->fetchAll('SELECT * FROM sh_users'));
use Aura\Sql_Query\QueryFactory;
$query_factory = new QueryFactory('mysql');
require_once BASEPATH . 'core/CodeIgniter.php';
both fragments are copied from documentation
var_dump gives perfect result, but QueryFactory gives me error
Fatal error: Class 'Aura\Sql_Query\QueryFactory' not found in F:\XAMPP\htdocs\codeigniter\public\admin\index.php on line 83
and i have no idea why. all vendors are downloaded and all php files are there, but it seems autoload doesnt load it. why?
Take a look at the file structure on disk; you may actually want to be including Aura\SqlQuery\QueryFactory, instead of something under the Sql_Query namespace. It may be something as simple as that. I've encountered issues when I've forgotten to rename the class in a PSR-0 compliant path such that it matches the file name, so if in fact the contents on the disk are in:
Aura\SqlQuery\QueryFactory but your use statement is Aura\Sql_Query\QueryFactory, you'll run into a problem.
As mentioned below in the comments, it appears that the Aura devs have two branches, the master branch on the Githup project auraphp/Aura.Sql_Query still has the directory structure as Sql_Query where as the default package, served by packagist, serves the dev-rename branch which replaces Sql_Query with SqlQuery.
Hope that helps!

Categories