Setting up php selenium test - php

i am trying to open firefox as the example explains herehttps://github.com/facebook/php-webdriver/blob/community/example.php with the following code:
<?php
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once 'C:\Users\alex\vendor\autoload.php';
$host = 'http://localhost:44441/wd/hub'; // i am running on 44441
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
?>
my composer composer.json at \alex\vendor\ looks like this:
// autoload.php #generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit95fa64adf2a94f75qbb05d3ee5a8af4e::getLoader();
my composer.json looks like this:
{
"require": {
"facebook/graph-sdk": "^5.6"
}
}
and my error is:
PHP Fatal error: Uncaught Error: Class
'Facebook\WebDriver\Remote\DesiredCapabilities' not found in
C:\Users\alex\Desktop\php-webdriver-community\hello.php:11
Stack trace:
#0 {main}
thrown in C:\Users\akal\Desktop\php-webdriver-community\hello.php on line 11
[Finished in 0.0s]
can anyone help?

To use the Facebook web driver, you need to install it using something like...
php composer.phar require facebook/webdriver
(From https://github.com/facebook/php-webdriver#installation )
In the project I use it, this includes a line in the composer.json...
"facebook/webdriver" : "^1.4"
and not the line you have with the graph-sdk

Related

PHP Fatal error: Uncaught Error: Class 'Adldap\Adldap\Configuration\DomainConfiguration'

Fatal error: Uncaught Error: Class 'Adldap\Adldap\Configuration\DomainConfiguration' not found in /var/www/html/accounts/ad/accounts.php:6 Stack trace: #0 /var/www/html/accounts/ad.php(15): include() #1 /var/www/html/accounts/index.php(72): include('/var/www/html/a...') #2 {main} thrown in /var/www/html/accounts/ad/accounts.php on line 6
accounts.php =
<?php
require_once __DIR__.'/../../vendor/autoload.php';
use Adldap\Adldap;
use Adldap\Utilities;
$config = new Adlap\Configuration\DomainConfiguration([
'hosts' => [
'XXXXXXXXXX',
],
]);
$ad = new \Adldap\Adldap();
$ad->addProvider($config);
try {
$provider = $ad->connect();
Make sure is exits Adldap\Adldap php package also for this you need install composer tool. . If it doesn't exits then add name of package to composer.json like this:
composer require vendor/package
For show installed packages enter:
composer show -i
After it you can use package easly.

Composer install error - jms-security-extra-bundle

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);

Error accessing class when using Composer autoloader

I have folder app/Controllers/HomeController.php and in my composer autoloader i write like this:
"autoload": {
"psr-4": {
"App\\": "app/",
}
},
but when i try to access my file from public/index.php like this:
require __DIR__ . '/../vendor/autoload.php';
$home = new \App\Controllers\HomeController;
I got some error like this:
Fatal error: Uncaught Error: Class 'HomeController' not found in E:\laragon\www\slim\public\index.php:14 Stack trace: #0 {main} thrown in E:\laragon\www\slim\public\index.php on line 14
so where i'm doing wrong here? for more info in my HomeController i using namespace like this:
namespace App\Controllers;
Ok the answer is I have to dumb my autoloader and it works.

Composer.json Installation On AWS Elastic Beanstalk

I read in the AWS Elastic Beanstalk documentation that you can simply include the composer.json file in the root of your package and it will install an application and it's dependencies:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-configuration-composer
{
"require": {
"coinbase/coinbase": "~2.0"
}
}
Then I created a PHP file with the following to test if it worked:
error_reporting(E_ALL);
ini_set('display_errors', 1);
$apiKey = 'workingkey';
$apiSecret = 'workingkey';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$buyPrice = $client->getBuyPrice('BTC-USD');
echo $buyPrice;
Unfortunately it gives the following error:
Fatal error: Uncaught Error: Class 'Coinbase\Wallet\Configuration' not found in /var/app/current/test.php:20 Stack trace: #0 {main} thrown in /var/app/current/test.php on line 20
I've tried everything I can think of to get this to work. What am I missing here?
You missed to include the autoloader of composer.
Add this at the beginning of your file and it should work:
require __DIR__.'/vendor/autoload.php';

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