Composer install error - jms-security-extra-bundle - php

I'm in the process of trying to upgrade a PHP application from Symfony 2.x to 3.x. I've managed to resolve dependency issues for the various packages we're using and all the packages download and install. However when the composer install triggers a cache clear it errors out with the following:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Warning: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: require_once(/home/vagrant/code/symfony/vendor/jms/security-extr
a-bundle/Tests/Functional/../../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/code/symfony/vendor/jms/secu
rity-extra-bundle/Tests/Functional/AppKernel.php:5
Stack trace:
#0 /home/vagrant/code/symfony/vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php(5): require_once()
#1 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(191): require_
once('/home/vagrant/c...')
#2 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(145): Symfony\
Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler->convertFileToClass('/home/vagrant/c...', '/home/vagrant/c...', 'JMS\\SecurityExt..
.')
#3 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/Fata in /home/vagrant/code/symfony/vendor/jms/security-extra-bundle
/Tests/Functional/AppKernel.php on line 5
Fatal error: Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler::main(): Failed opening required '/home/vagrant/code/symfony/v
endor/jms/security-extra-bundle/Tests/Functional/../../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/vagrant/code/symfony/vendor/j
ms/security-extra-bundle/Tests/Functional/AppKernel.php on line 5
The file it's referring to has these lines at the top:
<?php
namespace JMS\SecurityExtraBundle\Tests\Functional;
require_once __DIR__.'/../../vendor/autoload.php';
There is no autoload.php at that path. I suspect that this file is being autoloaded when it shouldn't be but I'm not sure how to resolve this.
I have compared the contents of the /vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php file to another Symfony 3 project that we have and it's exactly the same so this leads me to think it's even more likely that this file is being autoloaded when it shouldn't be.
What can I do to resolve this and get past the cache:clear --no-warmup command?

I have now resolved this. I had originally copied bin/console from another Symfony 3 project. It seems however that the correct approach was to move the existing app/console to the bin/console path and update the include paths to correctly reference the bootstrap.php.cache file in ../var/ and the autoload.php and AppKernel.php in ../app. The whole bin/console file now looks like this:
#!/usr/bin/env php
<?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../var/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

Related

Agent Library at Laravel. What's Wrong?

what's up?
I found this problem: I initiate a new project from 0, installing Laravel with composer:
composer create-project laravel/laravel --prefer-dist Blog
The following step was to add the Agent library https://github.com/jenssegers/agent.
composer require jenssegers/agent
This is the first library that I have ever used on Laravel and I'm not sure if I did it correctly. I added the line codes mentioned in the Agent's README.md at the config/app.php. After it, I went to public/index.php at my project and add the following lines to test it:
use Jenssegers\Agent\Facades\Agent;
$agent = new Agent();
Infortunally it didn't work and I had received the following error: Fatal error: Uncaught Error: Class "Jenssegers\Agent\Facades\Agent" not found in C:\xampp\htdocs\BlogBRU\public\index.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\BlogBRU\public\index.php on line 7. The line 7 correspond to $agent = new Agent();
I already tried to modify the use ... for:
use use Jenssegers\Agent\Facades;
use Jenssegers\Agent\Agent;
But it doesn't work.
I will appreciate it if you could help me. This is taking all my time!

PHP Startup: Failed opening index.php after composer install/update

I've uploaded my webapp (made with Laravel 5.8). I run composer install via SSH so vendor is created, but when opening website I get:
Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 24
Fatal error: PHP Startup: Failed opening required '//../vendor/autoload.php' (include_path='.:/:/usr/local/php72/lib/pear') in /index.php on line 24
When I change server's PHP default version, for example to 7.1, in second line path changes to: usr/local/php71/lib/pear .
On localhost, and on different with the very same vendor everything works fine.
So I assume something is wrong with php's path?
I've already run composer update or dumb-autoload with no success.
E1:
define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
try to run following command in your application
sudo chmod -R 777 bootstrap/cache storage

composer can not find classes and load them

I am using a Dropbox api package and installed it with Composer.When I try to use classes that gives me a fatal error that can not find classes.
This is my composer.json
{
"require": {
"kunalvarma05/dropbox-php-sdk": "^0.2.1"
}
}
This is my php file
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;
$app = new DropboxApp("client_id", "client_", 'access_token');
//Configure Dropbox service
$dropbox = new Dropbox($app);
//Get File Metadata
$fileMetadata = $dropbox->getMetadata("/helloworld.txt");
//File Name
// $fileMetadata->getName();
printf($fileMetadata->getName());
My php version is 7.2.4 and the error is:
Fatal error: Uncaught Error: Class 'Kunnu\Dropbox\DropboxApp' not found in D:\MeHDi\Projects\DropBox Api\Upload.php:6
Stack trace:
#0 {main}
thrown in D:\MeHDi\Projects\DropBox Api\Upload.php on line 6
Have you remembered to import composers autoload file using require "path/to/vendor/autoload.php";
This is required in order to initialize and use the different composer libraries. Remember to change the filepath to where your vendor/autoload.php file is located.

Missing Classes in Authorize.net PHP SDK

I'm trying to generate a custom report from Authorize.net using their API but cannot get the SDK to load without errors.
I created a post on the developer board HERE as well as sending an email request to their support team. The issue was supposed to have been fixed with a temporary patch HERE. But the errors persist.
Does anyone have any ideas as to how to work around this issue?
My Code:
<?php
error_reporting(-1); ini_set('display_errors', 'On');
date_default_timezone_set('UTC');
/* autoload through composer */
//require 'vendor/autoload.php';
/* autoload through git clone */
//require 'git/sdk-php/autoload.php';
/* autoload through .zip download */
require 'download/sdk-php-master/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
function getSettledBatchList($startDate, $endDate) {
$api_id = "MY_API_ID";
$account_key = "MY_ACCOUNT_KEY";
$start_dt = new DateTime($startDate);
$end_dt = new DateTime($endDate);
$merchAuth = new AnetAPI\MerchantAuthenticationType();
$merchAuth->setName($api_id);
$merchAuth->setTransactionKey($account_key);
$request = new AnetAPI\GetSettledBatchListRequest();
$request->setMerchantAuthentication($merchAuth);
$request->setIncludeStatistics(true);
$request->setFirstSettlementDate($start_dt);
$request->setLastSettlementDate($end_dt);
$controller = new AnetController\GetSettledBatchListController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if(($response != null) && ($response->getMessages()->getResultCode() == "Ok")){
/* Do Nothing For Now */
}else{
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
return $response;
}
$api_response = getSettledBatchList('2016-05-01T00:00:00Z', '2016-05-10T00:00:00Z');
var_dump($api_response);
?>
The Errors:
/* Loaded with git clone https://github.com/AuthorizeNet/sdk-php.git */
Warning: include(sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in sdk-php/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in sdk-php/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded by downloading .zip from github page */
Warning: include(/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in /sdk-php-master/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in /sdk-php-master/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php-master/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded with Composer using recommended composer.json */
Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82
I'm open to all ideas at this point. Thanks!
Simple mistake. The patch was to the composer.json file that updated the required-dev version of Goetas. Did not realize I needed to update my composer.json before running composer update.
Updated composer.json Language
I just had the same issue, and I realized that the problem is that I was using require on the wrong autoload.php and I think you're doing that too.
You probably have figured it by now but in case someone else has this problem the solution is this:
You have to load/require the autoload.php that's inside the vendor folder, not the one inside the sdk (root) folder.

PHPunit in zendframework 2

i'm trying to use phpunit with zendframework and i'm follwing the tutorial in
https://media.readthedocs.org/pdf/zf2/latest/zf2.pdfhere is my
bootstrap.php
<?php
chdir(dirname(__DIR__));
include __DIR__ . '/../init_autoloader.php';
here is my IndexControllerTest.php
<?php
namespace ApplicationTest\Controller;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
class IndexControllerTest extends AbstractHttpControllerTestCase
{
public function setUp()
{
$this->setApplicationConfig(
include '/C:/wamp/www/zf2/config/application.config.php'
);
parent::setUp();
}
public function testIndexActionCanBeAccessed()
{
$this->dispatch('/'); // this is line 20
$this->assertResponseStatusCode(200);
$this->assertModule('application');
$this->assertControllerName('application_index');
$this->assertControllerClass('IndexController');
$this->assertMatchedRouteName('home');
}
}
and i'm getting the follwing errors
Warning: include(C:\wamp\www\zf2\module\Application\test/../init_autoloader.php)
: failed to open stream: No such file or directory in C:\wamp\www\zf2\module\App
lication\test\Bootstrap.php on line 4
Fatal error: Class 'Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase'
not found in C:\wamp\www\zf2\module\Application\test\ApplicationTest\Controller
\IndexControllerTest.php on line 8
i think that's a path probleme (auloading)but i don't know how to fix
any one can help me please ?
Warning: include(C:\wamp\www\zf2\module\Application\test/../init_autoloader.php)
: failed to open stream: No such file or directory in C:\wamp\www\zf2\module\App
lication\test\Bootstrap.php on line 4
This warning is telling you that it can't find the location of your init_autoloader.php file. Assuming that file is located in the root of your ZF2 project (so C:\wamp\www\zf2) as is convention, you need to change:
include __DIR__ . '/../init_autoloader.php';
to
include __DIR__ . '/../../../init_autoloader.php';
EDIT Continued...
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to
load ZF2. Run php composer.phar install or define a ZF2_PATH environment
variable.' in C:\wamp\www\zf2\init_autoloader.php:48
Your init_autloader.php file is having trouble finding your ZF2 library autoloader. As you're using composer. Add
"zendframework/zendframework": "2.1.*",
to your "require" section in composer.json if its not already there. Run composer and update your vendor libraries with
php composer.phar update
Try run the application again and see if it works. It may do depending what is included in your init_autoload.php file. If you're still having problems add the following to init_autoloader.php
if(file_exists('vendor/autoload.php'))
{
$loader = require 'vendor/autoload.php';
}
Here's the Fix for the fatal error.
You must be missing the 'zend-test' package in your application.
$ composer require zendframework/zend-test

Categories