laravel giving error failed opening required thrn (file path)(include_path='C:\xampp\php\PEAR')in (file path)
//my index file code id shown below
//require __DIR__.'public/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'].'public/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
//$app = require_once __DIR__.'/public/bootstrap/app.php';
$app = require_once (realpath($_SERVER["DOCUMENT_ROOT"]).'/public/bootstrap/app.php';
If this is a new installation, you need to run composer install.
If it's an existing installation (vendor folder exists) run composer update.
Step 1:
Run: Composer Install for new Installation.
Run: Composer Update for Existing Installation.
Step 2: Make .env file
Step 3: Run: Php artisan migrate (Make database )
Step 4: Run: Php artisan key:generate
Related
I've a project I try to run it but I am getting a following error:
PHP Fatal error: Class 'Dotenv' not found in `/home/maras/Documents/eCodile/debtorcare/server/bootstrap/app.php on line 5`
I'm struggling with this error during trying to execute a php artisan start I tried to reinstall all dependencies but it didn't work.
I've just tried to run some commands based on other similar problems I found in the Internet but any of them worked. I tried ie:
composer require vlucas/phpdotenv --prefer-dist
Ive got a file .env.
This is a file where error is placed:
<?php
require_once __DIR__.'/../vendor/autoload.php';
Dotenv::makeMutable();
Dotenv::load(__DIR__.'/../');
Dotenv::makeImmutable();
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
Is it possible the error is connected with wrong configuration of a database or phpMyAdmin? Or maybe Ive got .env placed in wrong place?
I try to run this project in development.
I guess the cwd was changed while you're running the command. make sure that composer.json, .env, "vendor/autoload.php" can be loaded from the project root.
maybe you need to run "composer dump-autoload" after the Dotenv installation,
As c9s suggests, Check to make sure that you are loading an existing vendor/autoload.php with something like:
$vendor_audoload = __DIR__.'/../vendor/autoload.php';
print $vendor_audoload;
if(file_exists($vendor_audoload)){
print " Exists!";
} else {
print " Does not exist!";
}
I am attempting to write a PHP script that I would like to run from the command line. I want to use composer to manage its dependencies, as well as to make it available to be installed as a dependency to other projects. I also want to maintain the ability to use it on its own (with its dependencies).
Currently, main.php is my "entry point" (what I would execute from the command line). As I built and tested it, I did so in the "stand alone" mindset. A such, main.php requires autoload like so:
<?php
require_once __DIR__.'/../vendor/autoload.php';
Continuing in stand alone mindset, I set it up like so:
git clone package into place
cd package
composer install
This produces the following directory setup"
package
|-composer.json
|
|-src
| |-ClassOne.php
| |
| |-ClassTwo.php
| |
| |-main.php
|
|-vendor
|-autoload.php
|
|-composer
|
|-3rdpaty_1
|
|-3rdpaty_2
This works well--I can run php src/main.php which is able to find the classes it needs because it loads __DIR__.'../vendor/autoload.php'.
Where I run in to trouble is when I want to install the package as a dependency to another project (in order to have the script available to run there). I add my package to the composer.json and it gets installed. Attempting to run php vendor/compnay/package/src/main.php fails, however, because the necessary autoload.php is in a different place:
dependent_project
|-composer.json
|
|-some_code
|
|-vendor
|-autoload.php
|
|-composer
|
|-company
| |-package
| |-composer.json
| |
| |-src
| |-ClassOne.php
| |
| |-ClassTwo.php
| |
| |-main.php
|
|-other_vendor_1
|
|-other_vendor_2
I understand what is wrong, but I am not sure how to fix it. How does one provide such a thing using composer? I've searched around a lot but I don't see anyone asking or answering the same question. I notice the bin property of composer.json and started looking into that idea, but I'm still not finding a lot of info on how to properly set up my script to find what it needs in the different contexts.
I considered trying to use include in an if, and running a second include to the other path on fail, but that doesn't seem like the proper way to go about it.
A common practice is to look into both locations for an autoload file. See for instance this snippet used by Behat:
function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
fwrite(STDERR,
'You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL
);
exit(1);
}
iam getting an error after uploaded project to server. when i visited to link somedomain.com/DEMO i got following error. What actually is this error? how can i solve it please help me.
Warning: require(/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php): failed to open stream: No such file or directory in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
Fatal error: require(): Failed opening required '/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
my index.php is like this:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/project/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/project/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
project is main folder . Inside projetc i have app,vendor,bootstrap,config,database,resources etc
Here are some of the best practices while launching a Laravel app on server.
Try them out. Might solve your issues. These steps have solved almost every problem that I have faced till now while launching a site on server.
1.Enable Mod_Rewrite
a2enmod rewrite
2.Install php 5.6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
While returning views, always use Foldername.viewname instead of Foldername\viewname
use public_path() while including files
chmod -R 777 "Storage folder path"
This file doesn't exist:
/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php
I'm trying to include a path to autoload.php which is in
vendor/autoload.php
the file trying to access it is in
public/this-file.php
I set the path to require_once '../vendor/autoload.php'; but it just throws the error -
Warning: require_once(../vendor/autoload.php): failed to open stream: No such file or directory
Fatal error: require_once(): Failed opening required '../vendor/autoload.php' (include_path='.:/opt/php55/lib/php')
Does laravel offer a shortcode to access files in the vendor file
You don't need to require autoload.php in a Laravel application, it's already being required. You can just add more package in your composer.json file or do a composer require in the command line, and it should work.
It is required in bootstrap/autoload.php, if you don't believe me. ;)
/*
|--------------------------------------------------------------------- -----
| Register The Composer Auto Loader
|------------------------------------------------------------------------- -
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
If it doesn't for some reason, try composer dump-autoload, which fixes a lot of "requiring" issues in Laravel, especially when working with seeders and that sort of thing.
Hi I am currently running through the ZF2 User Guide trying to run a PHPUnit Test on the skeleton application as outlined here http://zf2.readthedocs.org/en/latest/user-guide/unit-testing.html.
But even though I have not edited the Module and have copied all the files from the tutorial every time I run the PHPUnit Test in Zend Studio I get this error
Error:
Fatal error: Class 'ApplicationTest\Bootstrap' not found in C:\Program Files (x86)\Zend\Apache2\htdocs\exerciseDB\module\Application\test\ApplicationTest\Controller\IndexControllerTest.php on line 24
But when I click on the Bootstrap::getServiceManager(); on line 24 Zend Studio takes me to the correct method.
File Stucture:
module
|_Application
|_config
|_language
|_src
|_test
|_ApplicationTest
| |_Controller
| |_IndexControllerTest.php
|_Bootstrap.php
|_phpunit.xml.dist
|_TestConfig.php.dist
Can anyine tell me where I am going wrong?
This was a really annoying bug that is somewhat of an irritation. Your phpunit config seems to be changed slightly from the one on the skeleton application. To give you direct answer that fixed my issue I did the following...
module
|_Application
|_config
|_language
|_src
|_tests
|_ZendApplicationModule
| |_Framework
| |TestCase.php
| |_IndexControllerTest.php
| |_SampleTest.php
|_Bootstrap.php
|_phpunit.xml.dist
|_TestConfig.php.dist
With the base setup as outlined above from the skeleton APP I had to add
require_once 'Framework/TestCase.php';
To SampleTest.php
For your actual fix you will need to require_once the file that is generating the issue. That should fix it.
Also make sure to update your autoload_classmap.php
I ran into the same issue where phpunit was not seeing my "module/Application/test/phpunit.xml.dist" file (I had it miss-spelled)
Try adding the file directly to the command line:
phpunit --bootstrap Bootstrap.php .
I had the issue as well.
I solved it by running phpunit from the root of my ZF2 project with the following arguments:
./vendor/bin/phpunit
--bootstrap ./module/Rest/test/Bootstrap.php
One can also specify the Test suite to use:
./vendor/bin/phpunit
--bootstrap ./module/Rest/test/Bootstrap.php
./module/Rest/test/RestTest/Controller/RestControllerTest.php
more details here