How to use libphonenumber for php - php

I was having difficulty getting libphonenumber for PHP to run as per this question.
All I got was:
My output:
Warning: require(/var/www/phone/libphonenumber/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/phone/libphonenumber/index.php on line 2
Fatal error: require(): Failed opening required '/var/www/phone/libphonenumber/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/php/PEAR:/var/www/cakephp/lib') in /var/www/phone/libphonenumber/index.php on line 2
What finally got it working was installing composer, and moving the generated composer.phar file into the libphonenumber folder, then running the install procedure. This step is missing from the docs, so I wanted to list it here. Thank you to #Simon_eQ for assisting me with this.

Try this command:
php composer.phar dump-autoload
This will generate autoload files if not already present.

Related

php warning require error

I need to make a CRUD application with laravel, and i installed it just like how it is supposed too but now i get this error. I am just checking what version of laravel i have installed but somehow this shows up? i am no expert on any means. Can someone help.
C:\Users\Gebruiker\blog>php artisan --version PHP Warning:
require(C:\Users\Gebruiker\blog\bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\Users\Gebruiker\blog\bootstrap\autoload.php on line 17
Warning:
require(C:\Users\Gebruiker\blog\bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\Users\Gebruiker\blog\bootstrap\autoload.php on line 17 PHP Fatal
error: require(): Failed opening required
'C:\Users\Gebruiker\blog\bootstrap/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\Users\Gebruiker\blog\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required
'C:\Users\Gebruiker\blog\bootstrap/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\Users\Gebruiker\blog\bootstrap\autoload.php on line 17
When you first create a laravel project, there's a folder called vendor that laravel needs. Laravel the framework itself exists there among other folders there. There is a file named autoload.php that is vendor folder that loads all the packages that laravel uses. For you to get these packages, you'll run this command below
composer install
then laravel can now work, so can php artisan command too.
you have to update your wamp server, the php version has to be at least 5.7
When starting any new Laravel project make sure you run composer install

Laravel - Can't run project

A friend send me a project but it is give me an error when i try run.
I go to project location and execute php artisan serve but i have this error:
Fatal error: require(): Failed opening required '/project1/bootstrap/../vendor/autoload.php' (include_path='.:') in /project1/bootstrap/autoload.php on line 17
When i run composer install i have this error:
[ErrorException]
file_put_contents(/project1/rev2/bootstrap/cache/ser
vices.php): failed to open stream: No such file or directory
What is the problem?
Thank you
Do you compose installed ? if not you can install it form here.
https://getcomposer.org/
Once composer is installed then you can run php artisan serve or you can place the project in the wamp/xampp project directory and run like this.
http://localhost/projectname/public
Make sure you have /project1/rev2/bootstrap/cache directory in your project location if not, you have to manually create it.

PhpStorm Laravel artisan Mamp

I'm learning PHP and wanted to work with Laravel, by doing so i follow tutorials and the guy explaining it uses artisan commands.
However I looked it up on how to add such commands but every time i go to command line tool support it gives me this error
Problem
Failed to parse output as xml: Error on line 2: Content is not allowed in prolog..
Command
php.exe D:\Websites\untitled\artisan list --format=xml
Output
Warning: require(D:\Websites\untitled\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in D:\Websites\untitled\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'D:\Websites\untitled\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') in D:\Websites\untitled\bootstrap\autoload.php on line 17
So i removed that project and installed Laravel again using "composer project"
and trying to add the artisan again doesn't work again with this fresh start.
Am I missing something? Or did I forgot something to do?
I hope someone can help me since I'm still a beginner and this would be a good learning school
Greetings
Ditger
Run composer install before using php artisan:
composer install

Composer - failed opening required for phpseclib

I am trying to run a PHP file in a Vagrant VM which also uses composer for the build.
I am getting the following errors:
PHP Warning: require(/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php): failed to open stream: No such file or directory in /var/www/ispe/vendor/composer/autoload_real.php on line 66
Warning: require(/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php): failed to open stream: No such file or directory in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required '/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66
Fatal error: require(): Failed opening required '/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66
Now as far as I can tell, phpseclib shouldn't be required for this particular functionality, or anything else (though I haven't 100% confirmed the anything else bit yet).
Even so, I decided to add it to my composer.json ("phpseclib/phpseclib": "2.0.4") to get rid of the errors, with no luck.
I'm fairly new to Composer, so I am wondering precisely what I might be doing wrong here or what needs to be setup.
I can confirm that the directory /var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/ exists, however there is no file bootstrap.php inside the directory.
Instead I see the following:
Crypt File Math Net System
EDIT: I also want to clarify that the file autoload.php is inside the vendor directory and that the PHP version of the VM is 7.0.
I strongly believe that the cache is the problem, It cannot be 100% sure but try destroying your Vagrant instance, or
You could follow the following steps:
Delete the vendor folder
Delete composer.lock
Run the command composer clearcache (or clear-cache)
Run composer install
Oneliner for easy copy/pasting:
rm -rf vendor composer.lock && composer clearcache && composer install

require_once(PHP/CodeCoverage/Filter.php): failed to open stream

I am trying to get familiar with testing (unit, functional) under Symfony 2.3.24/Windows7/PHP 5.4.7.
It seems PHPUnit is installed correctly (via Composer), but when I run a phpunit -c app/ command I get the following error:
Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in C:\xampp\php\phpunit on line 38
Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\php\phpunit on line 38
I googled for the issue to no avail. I additionnaly found in the official PHPUnit website that The code coverage report feature requires the Xdebug (2.1.3 or later) and tokenizer extensions.
What do you think about all this? your help is much appreciated.
In current versions of PHPUnit the phpunit script does not include PHP/CodeCoverage/Filter.php directly. It appears you are using an outdated version of PHPUnit and/or have a mixup of Composer/PEAR installations.
Please follow the instructions on https://phpunit.de/getting-started.html to properly install PHPUnit. And http://thephp.cc/news/2015/01/phpunit-migration-from-pear-to-phar explains how to migrate from a PEAR-based installation to Composer or PHAR.

Categories