I have created custom helper laravel 5.2. I put in folder App/Helpers/Global.php.
and autoload files in composer.json :
"autoload": {
"files" : [
"App/Helpers/Global.php"
]
}
On my Windows PC, it's working fine, but when i deploy to VPS centos I got this error.
PHP Warning: require(/xxxx/xxxxx/public_html/xxxx/vendor/composer/../../App/Helpers/Global.php): failed to open stream: No such file or directory in /xxxx/xxxx/public_html/xxxx/vendor/composer/autoload_real.php on line 66
why Autoloading "files" is relative to vendor directory ?
Thanks in advance.
error custom helper
It seems that OS on your VPS has case sensitive filename file system unlike Windows.
Just replace "App/Helpers/Global.php" with "app/Helpers/Global.php" and it should help.
Related
I'm trying to use the laravel 5.7 bootstrap4 preset, but have problems using it.
Do you guys know why I see this error? Why is the file missing? I have not changed the path to anything.
kgp43:~/workspace (master) $ php artisan preset bootstrap
In Bootstrap.php line 41:
copy(/home/ubuntu/workspace/resources/sass/_variables.scss): failed to open stream: No such file or directory
I found the error.
All folders in the Assets directory has to be moved up one level.
It should not be needed to move the content of the Assets folder (accoring to laravel - but it was for me to run the preset command.
https://laravel.com/docs/5.7/upgrade
I'm trying to change the directory of my dependencies on a Symfony 3.4 application.
I need that because I'm working on macOS with Docker and I'd rather have them not shared with the host since the file synchronization is too slow.
The related documentation, says:
The change in the composer.json will look like this:
{
"config": {
"bin-dir": "bin",
"vendor-dir": "/some/dir/vendor"
},
}
That I did
Then, update the path to the autoload.php file in app/autoload.php:
// app/autoload.php
// ...
$loader = require '/some/dir/vendor/autoload.php';
I don't have any autoload.php file in my app directory.
Am I missing something in the doc ?
The application generates the following fatal error:
Warning: require(/some/dir/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php): failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 66
Fatal error: require(): Failed opening required '/some/dir/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php' (include_path='.:/usr/local/lib/php') in /vendor/composer/autoload_real.php on line 66
I originally created the application with:
$ composer create-project symfony/framework-standard-edition test "3.*"
Open your composer.json file in editor.
Look for "autoload-dev" section
Remove whole "files" part (if exist)
Save file
Run composer install once again
Enjoy the party.
Sample code:
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
},
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
In Symfony 3.4, the file app/autoload.php is removed so you should:
replace old vendor path by the new vendor path directly in web/app.php, web/app_dev.php, bin/console and var/SymfonyRequirements.php files
Rerun the command $ composer install
I had the same issue and it was resolved doing the next.
Follow these 3 steps
1. First of all, modify composer.json to use the new vendor path:
"config": {
...,
"vendor-dir": "/app-vendor"
},
And remove the next line:
"files": ["vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"]
2. Secondly, if you are using docker-compose add a new volume where you'll put your vendors.
volumes:
...
- /app-vendor
PD: /app-vendor is a mounted volume which is now empty directory.
3. Lastly, write require '/app-vendor/autoload.php'; to:
my_project_name/bin/console
my_project_name/web/app.php
my_project_name/web/app_dev.php
PD1: Simply, this line is pointing to the new vendor path.
PD2: It's not necessary to modify any other file (like var/SymfonyRequirements.php as I could read).
Check your changes
Once the changes are ready, remove vendor/ and also remove the containers to avoid future problems.
Start your new containers and execute composer install. Now, /vendor will be /app-vendor, it won't be in the root folder of the project anymore.
For more details, I'd recommend you to go to my docker-symfony repository and check the commits. You'll see a benchmark progression and another tips like cached volumes and non-shared /cache && /logs folders.
All for Symfony 3.4.
I m getting thiserror`
Fatal error: require(): Failed opening required
'/home/goboot5e/public_html/myproject/vendor/composer/../../App/Http/helpers.php'
(include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php')
in
/home/goboot5e/public_html/myproject/vendor/composer/autoload_real.php
on line 66
when i have uploaded my project to the server(made live)
the things i have changed are(was working perfect on localhost):
copied all public files into server root ie public_html
database configured through .env file
changed path in the index.php(now public_html/index.php)
Most importantly i have made a custom helpers.php which is located in App/Http/helpers.php
my composer.json file autoload look like this
"autoload": {
"classmap": [
"database"
],
"files": [
"App/Http/helpers.php"
],
"psr-4": {
"App\\": "app/"
}
},
Please help me thanks in advance!!!
Try this. This problem occurs because laravel folder name is app but you use App. It works fine on localhost because windows OS is not case sensitive but linux is case sensitive. May be your PC is windows and server is linux
"files": [
"app/Http/helpers.php"
],
After changing run composer dump-autoload and upload your project again
Note : You can now upload only composer folder (vendor\composer) and autoload.php (vendor\)
Check the spelling of the files names. your localhost's filesystem is case-insensitive, while the server is not.
double check that all names casing match with composer.json.
For example, if helpers.php is Helpers.php composer will not find the file.
Tried to run the trans.php program from wamp server from the path
C:\wamp\www\sep24\e\trans.php
I have included the AWS folder in
C:\wamp\www\sep24\e\Amazon\
And AWS credential file in wamp/www folder as well user directory for the access
C:\wamp\www\.aws\credentials & C:\Users\username\.aws\credentials
This is my program
<?php
define('ROOT', dirname(__FILE__));
require ROOT . '/vendor/autoload.php';
use Amazon\Aws\ElasticTranscoder\ElasticTranscoderClient;
-------------
------------
// no error here.
?>
When i'm trying to run the program, I get this error
Fatal error: require(): Failed opening required 'C:\wamp\www\sep24\e/src/functions.php' (include_path='.;C:\php\pear') in C:\wamp\www\sep24\e\vendor\composer\autoload_real.php on line 54
I have included all the packages of AWS which I downloaded from the git.
What change should I make ?
There are two main problems are:
1 Composer Autoloading
The AWS dependency needs to be downloaded with Composer,
if you want the Composer Autoloader to work correctly.
Do not move folders around, when working with Composer.
The autoloading expects the files and folders inside the vendor folder.
I have included all the packages of AWS which I downloaded from the git.
You don't need to do this manually.
2 The use statement is wrong.
Change use Amazon\Aws\ElasticTranscoder\ElasticTranscoderClient;
to use \Aws\ElasticTranscoder\ElasticTranscoderClient;
3 Example Application
Because it is your third question and you seem to have problems with the application structure in connection with Composer, i will provide a simple PHP application template to demonstrate how you work with the AWS dependency.
This example provides a basic namespaced PHP application and includes the Client class from the AWS dependency(, which you have to fetched by Composer).
You find the file over here:
https://www.dropbox.com/s/q1b406thgu3146n/php-app-composer-aws.zip?dl=0
Extract the test folder into your www folder.
Then execute a composer install and run index.php.
You will end up with a error from TranscoderClient, because it expects a configuration. Not part of the problem.
Use composer.
Create testaws directory and put composer.json file with content below (you can adjust it to your needs for example PHP version or dev packages)
{
"name": "yourname/sampleapp",
"description": "Sample app",
"require": {
"php": ">=5.5.0",
"aws/aws-sdk-php" : "dev-master"
},
}
run composer install
then in index.php in testaws directory put this line in index.php
require __DIR__ . '/vendor/autoload.php';
After you do this steps it should work. More about composer you will find there
Also you can find sample project here
Delete the vendors folder and run composer install.
Environement
Windows 7
WAMP server
PHP 5.3.13
Apache 2.2.12
MySQL 5.5.24
Laravel 4.1
I installed laravel, trying to run the URL
http://localhost/laravel/public
autoload.php
define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
if (file_exists($compiled = __DIR__.'/compiled.php')){
require $compiled;
}
Illuminate\Support\ClassLoader::register();
if (is_dir($workbench = __DIR__.'/../workbench')){
Illuminate\Workbench\Starter::start($workbench);
}
I am facing the following errors:
Warning: require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\laravel\bootstrap\autoload.php on line 17
and
Fatal error: require() [function.require]: Failed opening required 'C:\wamp\www\laravel\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') in C:\wamp\www\laravel\bootstrap\autoload.php on line 17
Go to the current Project folder
C:\wamp\www\laravelProjectFolder>
and type composer install in command prompt and press ENTER key.
composer install
Then the vendor directory will be downloaded in the current project of laravel.
Now refresh the screen.
Simply make your storage folder writable. This can be found in your app directory
In your terminal use this command
chmod +w <directory> or chmod a+w <directory>
Make sure you navigate to the directory containing the directory you want to make writable or you point to that path.
go to your project folder via cmd. run the following command
composer update
it will install missing vendor folder and files in your project.
but in some cases it gives error like " Your configuration does not allow connection to bla bla bla.."
for that go to your composer.json file,
change "secure-http": true to "secure-http": false
but in some cases (as was in my case) you may not find such line in your file. for that do the following action:
change "config": {
"preferred-install": "dist"
}
to
"config": {
"preferred-install": "dist",
"secure-http": false
}
and run again composer update command.
hope this will solve problem of many persons. :)
You are trying to include:
C:\wamp\www\laravel\bootstrap/../vendor/autoload.php
and the error gives
No such file or directory in
C:\wamp\www\laravel\bootstrap\autoload.php on line 17
so you need to check your directory layout. Is there a directory vendor in lavarel with a file autoload.php in it?
and you should either have / in your pathnames or \ but not mixed both.