I have laravel 5 in a remote server and I have this error Class 'App\Libraries\CheckLang' not found.
In CheckLang namespace App\Libraries;
in routes.php use App\Libraries\CheckLang;
In local it works but in the remote server no.
I create a folder myapplication with the folders of laravel and in public_html the files of the folder public.
I have modified index.php
require __DIR__.'/../ myapplication/bootstrap/autoload.php';
$app = require_once __DIR__.'/../myapplication/bootstrap/app.php';
Thank you
Try this:
composer update
See, if that helps.
Thank you for Ammadu,
it was a problem of uppercase.
Related
I created the Laravel project and I uploaded it into a shared server. Inside the server, I tested the application some controllers are not working but in the local, I tested it's working without issues.
When I tested the application in server it's saying
ReflectionException (-1)
Class Asset_Management_System\Http\Controllers\SublocOneController
does not exist
I don't know what was the issue please help me to fix this issue.
Controller File
namespace Asset_Management_System\Http\Controllers;
use Illuminate\Http\Request;
use Asset_Management_System\MainLocation;
use Asset_Management_System\SubLocationOne;
class SubLocOneController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
}
Web.php file
Route::resource('SubLocationOne','SubLocOneController');
Try to connect via ssh to the server and run in the root of the site:
composer dump-autoload
Are u renaming the app file in laravel structure with Asset_Management_System ?
basically if u make controller with this path :
App\Http\Controllers\[YourControllerName];
1.1 just do this :
namespace App\Http\Controllers;
In other case, you can use composer dump-autoload in terminal inside your directory.
Typo SublocOneController and SubLocOneController?
I have project on localhost and I Need someone can help me to deploy lumen framework to hosting, i have been search in google for deploy lumen but i just found deploy laravel, maybe laravel and lumen is the same framework but i don't know how to deploy the lumen framework to my shared hosting in subdomain.
I have be been upload to :
/home/usernamecpanel/lumen
and public folder i put to my subdomain like
/home/usernamecpanel/public_html/subdomain/index.php
/home/usernamecpanel/public_html/subdomain/.htaccess
but i just got error 500.
oh, before i run i have been edit index.php to directing to lumenproject :
$app = require __DIR__.'/../../lumen/bootstrap/app.php';
I really confuse and i have been search in few day but cannot found the solution, i think someone can help me.
thank you.
Thanks for reviewing my edit
How to Fix it?
Zipping your Lumen Project
Go to your shared hosting file manager
I assume your shared hosting file manager have this directory structure like /home/username/public_html.
Create a folder outside public_html or htdocs, the folder name is up to you, example "myfolder" the structure looks like /home/username/myfolder
Upload your project to the new folder you have been created and unzip.
After unzip, inside the "myfolder" there is a folder named "public", move the contents inside to
For Main Domain
/home/username/public_html
For Subdomain or Subfolder
/home/username/public_html/sub
After moving those files, edit the index.php inside /home/username/public_html or /home/username/public_html/sub
Inside the file you see this code
$app = require __DIR__.'/../bootstrap/app.php';
change the code to
For Main Domain
$app = require __DIR__.'/../myfolder/bootstrap/app.php';
For Sub Domain/Subfolder
$app = require __DIR__.'/../../myfolder/bootstrap/app.php';
Don't forget to edit the APP_URL in .env file inside "myfolder"
Example the APP_URL .env file
APP_URL=http://yourdomain.com or http://sub.yourdomain.com or http://yourdomain.com/sub
I not got any answer from stackoverflow, and doesn't one onswer my question in stackoverflow, so i try hard find own solution with manual upload my lumen application in my shared hosting.
just put your lumen application in outside public_html and put your index.php file to subdomain and edit index.php set route to your subdomain.
if anyone have problem like me and read this question, you can ask from this question, i will help you if i got notice from this page.
You will need to move it with FileZilla to a subfolder inside /var/www/html/foldername and set configuration to the directory, but I wouldn't recommend you to set up a Micro Service in Shared host.
I'm trying to remove the public/index from laravel url, since this is one of the common question so there are lot of tutorials and answer. I also searched about this and followed the #rimon.ekjon answer which is working fine for me it's pretty simple.
Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder. -- Thats it !! :)
I'm confuse why i should rename or move something from one place to another because there will be a reason why files exist in public folder. I want to show another good answer which is also following the almost same pattern.
I'm thinking that by following above answers' step may be create some issues in future if there will be a new requirement or new feature request in the project.
So can anyone guide me is there any best to rewrite or remove the public/index from laravel 5. I would like to appreciate if someone guide me.
You should configure your web server's document / web root to be the public directory. That way you don't have to copy/move/delete anything.
For apache you can look here.
For nginx you can read here.
I've visited your link and saw really terrible advices.
You do no need to move any Laravel files or modify them. What you need is to setup web server. You need to point it to a public directory which is inside Laravel project root folder.
Please look here for an example config directives for Apache and nginx.
One other option is to symlink the public folder to your server's root folder (e.g. /var/www/). This article is a great guide on how to do this.
On your dev environment however you can use php artisan serve.
In case, if you don't have access to you server config, this is a perfect solution https://stackoverflow.com/a/32580688/5015089 .
Remove public from url without htaccess. It will work on laravel latest versions also.
step 1. Copy all files from public and paste on root directory
step 2. Open index.php file remove ../ from path as given below
Laravel5:
require __DIR__.'/../bootstrap/autoload.php';
to
require __DIR__.'/bootstrap/autoload.php';
and
require_once __DIR__.'/../bootstrap/app.php';
to
$app = require_once __DIR__.'/bootstrap/app.php';
Laravel 7:
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
please guide me how to upload the Laravel project to my cPanel I am very much confused.
you should add all the folders of laravel inside of public_html folder, and you need to move index.php and .htaccess file to the public_html directory from public directory. Now make changes index.php like this.
require DIR.'/bootstrap/autoload.php';
$app = require_once DIR.'/bootstrap/start.php';
That may work for you.
If you check your laravel project, there is a public folder inside it.
By default, your domain is pointed at the root level or on public_html. On you cPanel Domain settings, make sure your domain is pointed your Laravel application public folder.
I am running the Yii2 framework locally, and I want to reuse an model I created in a earlier project.
So I copy the file TestForm.php to the models directory, change the namespaces from namespace backend\models to namespace app\models and try to create an object from it with:
$model = new \app\models\TestForm;
Which gives me
Unable to find 'app\models\TestForm' in file: /var/www/html/operators/basic/models/TestForm.php. Namespace missing?
Which is weird because the namespace is correct.
However, if I create the file TestForm.php myself and copy the contents of the older file over, everything works fine.
What's going on?
(I use ubuntu 15.04)
I think in your /models/TestForm.php you don't have specified the correct namespace eg :
namespace basic\models;