unable to live site in server laravel5 - php

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

Related

PHP Warning: require_once

I'M Trying to run a cloned project and set my php evironment but everytime i try to execute php artisan serve commad,it gives me this error... the problem is that im new to laravel...
almando#almando-ThinkPad-Edge-E531:~/Documents/laravelPro/active-ecommerce$ php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Mon Dec 19 00:16:03 2022] PHP Warning: require_once(/home/almando/Documents/laravelPro/active-ecommerce/public/index.php): failed to open stream: No such file or directory in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:03 2022] PHP Fatal error: require_once(): Failed opening required '/home/almando/Documents/laravelPro/active-ecommerce/public/index.php' (include_path='.:/usr/share/php') in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:03 2022] 127.0.0.1:35764 [200]: /favicon.ico
[Mon Dec 19 00:16:10 2022] PHP Warning: require_once(/home/almando/Documents/laravelPro/active-ecommerce/public/index.php): failed to open stream: No such file or directory in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
[Mon Dec 19 00:16:10 2022] PHP Fatal error: require_once(): Failed opening required '/home/almando/Documents/laravelPro/active-ecommerce/public/index.php' (include_path='.:/usr/share/php') in /home/almando/Documents/laravelPro/active-ecommerce/server.php on line 21
^C
I don't know where to make changes is there someone who help me out on this, i will appreciate it..
below is the server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Naft Otell <naft#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
below is the index.php
<?php
ini_set('serialize_precision', -1);
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| 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 great to relax.
|
*/
require __DIR__.'/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__.'/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::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
The question is how would you solve this if it was you?
Thank you
Assuming folder doesn't have the permissions needed, try with this:
chown -R {username}:www-data /home/almando/Documents/laravelPro/active-ecommerce
chmod -R 750 /home/almando/Documents/laravelPro/active-ecommerce
chmod -R 770 /home/almando/Documents/laravelPro/active-ecommerce/storage

laravel new; application already exists error

I have installed Laravel before and I deleted that folder, and now after several months I install Laravel installer but when I write the command laravel new in Windows Powershell it returns this error.
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
In NewCommand.php line 153:
Application already exists!
new [--dev] [--jet] [-f|--force] [--] [<name>]
I created project. But I deleted it. When I create project again with the same name, I encountered this problem. After, I runned this command:
laravel new project-name --force
Only, I added --force end of command.
I have faced the same issue while creating a new project on the latest Laravel through Composer but didn't find any solution and at the last, I tried to create a Laravel project by the following command and it's working as expected.
composer create-project --prefer-dist laravel/laravel ProjectName
or, you should remove that folder and let it be created by command as follows:
laravel new ProjectName
Explanation:
As I get the following error.
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
In NewCommand.php line 184:
Application already exists!
new [--dev] [--jet] [--stack [STACK]] [--teams] [-f|--force] [--] [<name>]
I tried to figure out this issue and found a function that is placed under %appdata%\Composer\vendor\laravel\installer\src\NewCommand.php on line 184 as follows:
/**
* Verify that the application does not already exist.
*
* #param string $directory
* #return void
*/
protected function verifyApplicationDoesntExist($directory)
{
if ((is_dir($directory) || is_file($directory)) && $directory != getcwd()) {
throw new RuntimeException('Application already exists!');
}
}
here verifyApplicationDoesntExist function is checking that the application folder you are trying to create has existed or not, it's not checking the application folder's size so it doesn't matter if the folder is empty or not. so due to code like that, the composer thinks application already been created that's why it throws an error like your application already exists.
To tackle this issue, you just need to delete your empty project folder and create it by command laravel new ProjectName and that will create project folder itself without giving any error like Application already exist!.
If you're having problems, delete the parent directory. There's a chance there are hidden folders scattered across it.
Otherwise you can try creating a new folder in another directory and running Laravel new in it.
The folder location doesn't matter, it just generates content of a Laravel app.
Once you've created a new folder, you can move all the files across to your other folder with the following:
mv laravel/* /var/app/myfolderlocation
It happened to me too.
Maybe you created your laravel project directly in your linux shell instead of making it through the power shell "indirect" interface to your linux machine.
In my case I solved it following the next steps:
1.- Deleting the laravel-project directly in the ubuntu linux shell. rm -R laravel-project.
2.- Then, through power shell i executed again the curl command in the "sublinux" terminal like this: curl -s https://laravel.build/example-app | bash
Then the process started without problems, creating all the laravel files and docker images and containers.
All the tutorials followed by me direct to the microsoft step by step tutorial,
https://learn.microsoft.com/en-us/windows/wsl/install-win10
but it hidden some key steps that you can find in this amazing video:
https://www.youtube.com/watch?v=rr6AngDpgnM, thank you dogcomp for take the time that need some begginers (and not so beginners, like me).
change your Newcommand.php file
with github Newcommand.php file
https://github.com/laravel/installer/blob/master/src/NewCommand.php
The error means that the directory already exists.
Do the following to get around.
Go to a temp directory.
Execute the laravel new project-name there.
Copy the contents of the newly created directory to the actual project directory.
Though this might be late but i think it might help someone in difficult times. This error is related to the folder already in existence
Here's how i was able solve this issue:
i closed the vscode holding reference to the folder i intend installing laravel in. then
cd .. to come out from the folder.
next up. laravel new [target-folder-name] -f
and problem solved.
I'm hoping this would help someone.
While previously you would need to first create the directory then cd the console there and run laravel new, but currently you have to:
First ensure the my-project directory does NOT exist.
Run laravel new my-project to create the directory for you.
Wait for composer install command (which will auto-run) to finish.
For me in the end, it just logs Application ready! Build something amazing.
But finally, maybe go further and edit the auto-generated ./my-project/.env file, for example, set DB_DATABASE to something other than my_project or change APP_URL=http://my-project.test to APP_URL=http://localhost address.

failed opening required in laravel warning and fatal error

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

How can I provide a script for PHP CLI via composer (as standalone, and as dependency)

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

Laravel 5 how to include autoload.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.

Categories