Laravel url without public folder - laravel

hi i am using wampserver for my project
and my project is in folder sss
so i must type this Url localhost\sss\public
and want to have this
localhost\sss\
to show my index page

Copy the public folder contents outside the public folder and open index.php which you copied outside the folder, than change the:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
to
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/start.php';
and you can access directly.

Related

Move Laravel project to subdomain where Wordpress is already installed

I created a subdomain and move whole project except public folder. Create mysql database and upload my database there. Now, in public_html folder I already have wp files so I created new folder there which I named same as subdomain. So, subdomain is something.something.com and now I have path public_html/something/public where I upload all from public folder. I try to rename files in index.php public foder:
require __DIR__ . '/../bootstrap/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';
to this:
require __DIR__ . '/../something/public/bootstrap/autoload.php';
$app = require_once __DIR__ . '/../something/public/bootstrap/app.php';
but still I get this:
And I edit .env file to find database. Where am I wrong?
Solved! It was PHP version mismatched. In local it was 7.1 but on server was 5. When I update on server it worked.

upload Laravel in subfolder

I have uploaded my public items in public_html/demo
other folders to /home/danior/source/
/home/danior/public_html/demo/index.php:
require __DIR__.'/../../source/vendor/autoload.php';
$app = require_once __DIR__.'/../../source/bootstrap/app.php';
/home/danior/source/server.php:
require_once __DIR__.'/../public_html/demo/index.php';
http://danior.ir/demo/
but there some unknown errors !
filesystem.php won't upload
I upload my projects like this, hope it will help-
Create a sub-domain/domain eg- demo
Upload public folder items in your sub-domain "demo".
Create another folder inside public_html eg- demo_support.
Compress rest of the files as xyz.tar and upload and decompress in public_html/demo_support and configure your .env according to you.
Now in your public_html/demo/index.php -
replace
require __DIR__.'/../bootstrap/autoload.php';
with
require __DIR__.'/../demo_support/bootstrap/autoload.php';
and
replace
$app = require_once __DIR__.'/../bootstrap/app.php';
with
$app = require_once __DIR__.'/../demo_support/bootstrap/app.php';

Laravel Project Directory Structure

i have developed a project with default directory structure.
But on production, i don't want public in URL.
What can be done.?
I tried changing the app path, but still not working.
Just copy index.php and .htaccess file from public directory and paste it in project root folter.
Then change bootstrap path in project root folder index.php file like below,
require __DIR__.'/bootstrap/autoload.php';
and
$app = require_once __DIR__.'/bootstrap/app.php';

How to run Laravel from root directory, not from public?

By default, Laravel project is run from the public directory. For this, I must enter http://localhost/public/.
How do I configure Laravel so that the website will appear to be from http://localhost/?
•Go to mainproject/public>>
a. .htacess
b. favicon.ico
c. index.php
d. robots.txt
e. web.config
1.cut these 5 files from the public folder, and then paste on the main project folder that’s means out side of public folder… mainproject/files
2.Next after paste ,open index.php ,modify
•require __DIR__.'/…/bootstrap/autoload.php'; to
•require __DIR__.'/bootstrap/autoload.php';
modify
$app = require_once DIR.'/../bootstrap/app.php'; to
$app = require_once DIR.'/bootstrap/app.php';
you can also watch this video for better understanding----------------
https://www.youtube.com/watch?v=GboCYqEbKN0
Setup your webserver (probably Apache or NginX) to use the public folder of your laravel app as root directory. Or use a public_html folder and symlink it to your public folder, which basically does the same.
open your project in visual studio code
in new terminal type
php artisan serve
and goto
http://127.0.0.1:8000

How to host laravel web application in Shared Hosting

I have developed a web application using Laravel 5.8, now I want to host that to a shared web server. What will be the folder structure and exact what to configure.
I have created a folder named laravel and kept all the project folders into that laravel folder, except project's public folder. I kept all the files and folders of public folder into public_html folder.
I have configured the index.php file of public_html folder as below.
a. require __DIR__.'/../bootstrap/autoload.php';
to,
require __DIR__.'/../laravel/bootstrap/autoload.php';
b. $app = require_once __DIR__.'/../bootstrap/app.php';
to,
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
$app->bind('path.public', function() {
return __DIR__;
});
*** I have solved the problem myself.
Step 1: I have found and installed laravel app into public_html folder from the cPanel
Step 2: Then I have moved everything into a folder named laravel except public folder into a new folder outside public_html folder
Step 3: Then I have moved everything from public folder into public_html folder
Step 4: Later I have followed the 2nd step above
Step 5: Then I have changed folder permission for storage folder and it works fine.
Step 6: Finally I have kept all other files and folders of the app developed in my local server into this newly installed app directories
Laravel default structure always better. its depend on your hosting place.
if your hosting place support for laravel framework then use default structure automatically public word redirect to project path.
Or if you need to ignore Public word in your Url
Copy all files form files put in to one folder ex:psl
copy public folder paste in to folder directory
change the index.php file in two place
require __DIR__.'/psl/bootstrap/autoload.php';
$app = require_once __DIR__.'/psl/bootstrap/app.php';
I had similar errors on my deploy and then I noticed that the path is kind of wrong:
require __DIR__.'/../laravel/bootstrap/autoload.php';
the leading / changes to the root of the drive, and then the .. are not doing anything. Removing that leading / on both require __DIR__ fixed it for me.
if you can not provide a link to the web root of the shared folder!
All except the Public folder to move to a higher level, such as a folder laravel - http://prntscr.com/bryvu7
(Maybe on hosting your folder - public. not a folder public_html)
Change file publi_html/index.php
line
require __DIR__.'/../bootstrap/autoload.php';
to
require __DIR__.'/../laravel/bootstrap/autoload.php';
And line
$app = require_once __DIR__.'/../bootstrap/app.php';
to
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
$app->bind('path.public', function() {
return __DIR__;
});
Change file laravel/server.php
line
require_once __DIR__.'/public/index.php';
to
require_once __DIR__.'/index.php';

Resources