PDFParser php loading library via composer - php

I am trying to use the library PDFparser using the composer.
I know it is installed in /home/servername/vendor/smalot/pdfparser
My php script is found in /home/servername/public_html/test.php
This is my code:
<?php
ini_set('display_errors',true);
include 'vendor/autoload.php';
$parser = new \Smalot\PdfParser\Parser();
?>
and this is the error I am getting:
Warning: include(vendor/autoload.php): failed to open stream: No such file or directory in /home/servername/public_html/test.php on line 3
Warning: include(): Failed opening 'vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /home/servername/public_html/test.php on line 3
Fatal error: Uncaught Error: Class 'Smalot\PdfParser\Parser' not found in /home/servername/public_html/test.php:4 Stack trace: #0 {main} thrown in /home/servername/public_html/test.php on line 4
What am I doing wrong? This is my first time using a php library

Related

PHP Fatal error: Uncaught Error: Failed opening required 'Mail.php'

ini_set("include_path", '/home/busaweb/php:' . ini_get("include_path") );
require_once "Mail.php";
include('Mail/mime.php');
Anyone who can explain why these lines serve code?
I have been getting an error message since a few days that these files are missing/not viewable, see error code below:
[01-Aug-2022 18:48:59 UTC] PHP Warning: require_once(Mail.php): Failed to open stream: No such file or directory in /home/vestad/public_html/forms/functions.php on line 4
[01-Aug-2022 18:48:59 UTC] PHP Fatal error: Uncaught Error: Failed opening required 'Mail.php' (include_path='/home/vestad/php:.:/opt/cpanel/ea-php80/root/usr/share/pear') in /home/vestad/public_html/forms/functions.php:4
Stack trace:
#0 /home/vestad/public_html/forms/offer_email.php(6): include()
#1 {main}
thrown in /home/vestad/public_html/forms/functions.php on line 4
Is there anyone who can explain what may be causing this suddenly and how to fix it? I use hosting from a cpanel environment.
Thanks in advance!

php artisan throws an error: Failed opening required

On the linux(Pop_OS) when I created a new laravel project, I tried to run php artisan and I get the following error:
PHP Warning: require(/home/dusan/freeCodeGram/vendor/autoload.php): Failed to open stream: No such file or directory in /home/dusan/freeCodeGram/artisan on line 18
PHP Fatal error: Uncaught Error: Failed opening required '/home/dusan/freeCodeGram/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/dusan/freeCodeGram/artisan:18
Stack trace:
#0 {main}
thrown in /home/dusan/freeCodeGram/artisan on line 18
I am new to php and laravel and only just starting to learn it, and also note I have installed laravel using composer.
Try this command in your project
composer update --ignore-platform-req=ext-fileinfo
i hope it was useful !

PHP artisan is not recognized

I'm trying to learn Laravel-The PHP Framework and wanted to use artisan.
I already installed Laravel globally and also created my first project but every time I run php artisan it doesnt recognize the command. I opened git on my project directory and sill not recognized.
It gives me this error:
$ php artisan
PHP Warning: require(C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
Warning: require(C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
PHP Fatal error: Uncaught Error: Failed opening required 'C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan:18
Stack trace:
#0 {main}
thrown in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
Fatal error: Uncaught Error: Failed opening required 'C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan:18
Stack trace:
#0 {main}
thrown in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
I tried downloading PHP manually or use the PHP from XAMPP but no changes.
I used php v8.0.2 and composer v2.0.11
You shouldn't install Laravel globally.
Go through this link:
How to Install Laravel on Ubuntu 20.04

Google Sign-In With PHP

I'm adding Google Sign-In to my site. I've followed the steps here with no problems, it's only when I authenticate with a backend server that I get an error (500 Internal Server Error).
I'm using the Download the Release instructions and downloading google-api-php-client-2.2.3.zip. I'm not sure if it's relevant but the PHP version installed on the server is PHP Version 5.2.17
Once unzipped, the contents of the file (src,vendor,composer.json,etc) are then all moved to the root folder of my project and uploaded to the server.
HTML is directly copied and pasted from the instructions in order to minimise human error on my end
function onSignIn(googleUser) {
var id_token = googleUser.getAuthResponse().id_token;
// console.log(id_token);
var xhr = new XMLHttpRequest();
xhr.open('POST', 'googleauth.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
console.log('Signed in as: ' + xhr.responseText);
};
xhr.send('idtoken=' + id_token);
var profile = googleUser.getBasicProfile();
sessionStorage.refName = profile.getId();
// console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
// console.log('Name: ' + profile.getName());
// console.log('Image URL: ' + profile.getImageUrl());
// console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
}
function signOut() {
sessionStorage.clear();
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
}
<?php
require_once 'vendor/autoload.php';
$id_token = $_POST["idtoken"];
echo 'test2';
?>
When I comment out the code in the 'vendor/autoload.php' file and instead only have it return "test1", the require_once successfully performs its function and "Signed in as: test1 test2" is successfully logged to the console.
However when I run the script as originally written by Google I get a 500 (Internal Server Error) and "Signed in as: " is logged to the console.
There are so many files in this api, I'm finding it impossible to navigate. And I'm also finding it hard to believe that Google would release something as important as this in a way that doesn't work straight out of the box.
From my perspective I think that I'm following the instructions verbatim, but does anyone have any suggestions of what they think I might be misinterpreting, or alternatively what I could try differently?
---------------edited to add error log from server (with personal details replaced with $ signs)-----------------------
$$$$$/error_log:
[25-Jul-2019 23:35:39] PHP Warning: require_once(__DIR__/composer/autoload_real.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /$$$$$$$/vendor/autoload.php on line 5
[25-Jul-2019 23:35:39] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/composer/autoload_real.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /$$$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 01:17:47] PHP Warning: require_once(__DIR__/composer/autoload_real.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /$$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 01:17:47] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/composer/autoload_real.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 20:05:09] PHP Fatal error: Uncaught exception 'Exception' with message 'This library must be installed via composer or by downloading the full package. See the instructions at https://github.com/google/google-api-php-client#installation.' in /$$$$$/src/Google/autoload.php:14
Stack trace:
#0 /$$$$$/googleauth.php(3): require_once()
#1 {main}
thrown in /$$$$$/src/Google/autoload.php on line 14
[26-Jul-2019 20:05:19] PHP Fatal error: Uncaught exception 'Exception' with message 'This library must be installed via composer or by downloading the full package. See the instructions at https://github.com/google/google-api-php-client#installation.' in /$$$$$/src/Google/autoload.php:14
Stack trace:
#0 /$$$$$/googleauth.php(3): require_once()
#1 {main}
thrown in /$$$$$/src/Google/autoload.php on line 14
[26-Jul-2019 20:18:25] PHP Fatal error: Uncaught exception 'Exception' with message 'This library must be installed via composer or by downloading the full package. See the instructions at https://github.com/google/google-api-php-client#installation.' in /$$$$$/vendor/Google/autoload.php:14
Stack trace:
#0 /$$$$$/googleauth.php(3): require_once()
#1 {main}
thrown in /$$$$$/vendor/Google/autoload.php on line 14
[26-Jul-2019 20:19:09] PHP Fatal error: Uncaught exception 'Exception' with message 'This library must be installed via composer or by downloading the full package. See the instructions at https://github.com/google/google-api-php-client#installation.' in /$$$$$/vendor/Google/autoload.php:14
Stack trace:
#0 /$$$$$/googleauth.php(3): require_once()
#1 {main}
thrown in /$$$$$/vendor/Google/autoload.php on line 14
[26-Jul-2019 20:25:41] PHP Warning: require_once(__DIR__/composer/autoload_real.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 20:25:41] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/composer/autoload_real.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 20:28:17] PHP Warning: require_once(__DIR__/composer/autoload_real.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 20:28:17] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/composer/autoload_real.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 22:09:46] PHP Warning: require_once(__DIR__/composer/autoload_real.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /$$$$$/vendor/autoload.php on line 5
[26-Jul-2019 22:09:46] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/composer/autoload_real.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /$$$$$/vendor/autoload.php on line 5
/$$$$$/vendor/Google/error_log:
[26-Jul-2019 20:22:48] PHP Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /$$$$/vendor/Google/Client.php on line 18
I re-read the API notes and it turns out that the PHP version does matter...
"REQUIREMENTS: PHP 5.4.0 or higher"
I've updated the version used on the server and am no longer receiving any errors

Loading Zend Classes Warning and Fatal Error

Output:
Popular on Instagram
Warning: require_once(Zend/loader.php): failed to open stream: No such file or directory in E:\Programs\XAMPP\htdocs\hashtag\list1.php on line 7
Fatal error: require_once(): Failed opening required 'Zend/loader.php' (include_path='.;E:\Programs\XAMPP\php\PEAR') in E:\Programs\XAMPP\htdocs\hashtag\list1.php on line 7
Code:
require_once 'Zend/loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
I've searched a lot but I cannot understand the procedure to solve the issue.

Categories