I am trying to build a website to practice a code where. I am finding a strange error
Which I am unable to replicate how to solve the issue.
I have followed the steps.
I already downloaded the Vendor by Composer and here is the code I have used. Then I installed last pacjage.
composer require vlucas/phpdotenv
.env
APP_URL=http://oxbir.me
APP_ENV=local
APP_NAME="ACSE E-Commerce Store"
index.php
<?php
require_once __DIR__.'/../bootstrap/init.php';
$app_name = getenv('APP_NAME');
echo $app_name;
init.php
<?php
require_once __DIR__.'/../app/config/_env.php';
_env.php
<?php
define('BASE_PATH', realpath(__DIR__.'/../../'));
require_once __DIR__.'/../../vendor/autoload.php';
$dotEnv = Dotenv\Dotenv(BASE_PATH);
$dotEnv->load();
Related
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
I was installing slim 3 according to Slim Documentation.After installing i have created index.php file.Given below:
index.php:
<?php
require 'vendor/autoload.php';
$app = new Slim\App();
$app->get('/hello/{name}', function ($request, $response, $args) {
$response->write("Hello, " . $args['name']);
return $response;
});
$app->run();
But when i run the application in http://localhost:8000 then i get a fatal error.I have searched and get some solution in stackoverflow.Those are:
PHP Fatal error: Class 'Slim' not found - Slim Framework 3
PHP Fatal error: Class 'Slim' not found
Composer autoloader + slim framework - fatal error: Class 'Slim\Slim' not found?
But those solution does not solve my problem.Have any specific solution of it?
ERROR:
Fatal error: Class 'Slim\App' not found in
C:\xampp\htdocs\api\index.php on line 5
And my directory format:
UPDATED:
vendor/autoload.php:
<?php
// autoload.php #generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit98cfb2e091de2f633f87c81d16402aec::getLoader();
vendor forlder:
The problem is that you have downloaded and extracted Slim manually into htdocs\api\Slim.
It wasn't fetched by Composer, then it would reside in the vendor folder (vendor/slim/slim) and the autoload would work automatically.
Add Slim to your composer.json and run composer install again:
{
"require": {
"slim/slim": "^3.0"
}
}
You already require the Composer Autoloader, so the depenendency should be found and loaded after it was fetched.
Referencing: http://docs.slimframework.com/start/get-started/
I've been trying to fix this for 5 hours now.
This is my current php code.
set_include_path("google-api-php-client-master/src/Google");
require_once 'Google/Client.php';
require_once 'Google/Service/YouTube.php';
The directory structure looks like this:
+/test/
+google-api-php-client-master/
test.php
So the php file is in the same directory as the google api folder. Unfortunately I always get an error:
Warning: require_once(Google/Client.php) [function.require-once]: failed to open stream: No such file or directory in /test/test.php on line 20
Fatal error: require_once() [function.require]: Failed opening required 'Google/Client.php' (include_path='google-api-php-client/src') in /test/test.php on line 20
I have also set the permissions for the file. I am really clueless.
EDIT: I've tried some stuff out randomly and this solution worked for me:
set_include_path("api/src/");
require_once 'Google/Client.php';
require_once 'Google/Service/YouTube.php';
Zend recommends this procedure:
defined('BASE_PATH')
|| define('BASE_PATH', realpath(dirname(__FILE__));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(BASE_PATH . '/Google'),
get_include_path(),
)));
require_once 'Client.php';
Give it a try.
Try this
require_once 'Client.php';
require_once 'Service/YouTube.php';
Try commenting set_include_path() function - as it worked for me
<?php
// Call set_include_path() as needed to point to your client library.
include_once 'includes/session_manager.php';
require_once 'Google/Client.php';
require_once 'Google/Service/YouTube.php';
?>
I have included autoload.php in the header of my site
include 'vendor/autoload.php';
From this i am receiving the following errors on my site:
Warning: require_once(DIR/composer/autoload_real.php)
[function.require-once]: failed to open stream: No such file or
directory in
/homepages/6/d416629391/htdocs/leftovercheese/vendor/autoload.php on
line 5
Fatal error: require_once() [function.require]: Failed opening
required 'DIR/composer/autoload_real.php'
(include_path='.:/usr/lib/php5') in
/homepages/6/d416629391/htdocs/leftovercheese/vendor/autoload.php on
line 5
My code is:
// autoload.php generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit8be239f5caef32db03f87bb271ed6012::getLoader();
PHP Version: 5.2.17
Any ideas?
run composer install
That will import your packages and create the vendor folder as well as the autoload script. Also, make sure your relative path is correct.
You have to load vendor/autoload.php, which will autoload that file for you:
require_once __DIR__ . '/vendor/autoload.php';
This is assuming that your file is located at the same directory level as the vendor directory.
Otherwise, adjust.
For me, I updated some folder names and these updated are not reflected in autoload_files.php and autoload_static.php. I just had to run php composer.phar dump-autoload.
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