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?
Related
I have created helper file in laravel. I want to use laravel functionalities.
I am not able to use use or namespace template in helper file.
code of helper file.
namespace App\Helpers;
class CommonFunctions {
public static function get_cat() {
}
}
I have linked this helper in config/app.php
When I use namespace in helper file then this error is displaying
Blade file code
Finally I found the issue.
Actually I am migrating site from laravel 5.2 to 5.7 and I was copying the old helper file to new that's why I got this error..
Previously I was using use and namespace together but after adding use statements only I solved the issue.
It might be the issue of namespace is not allowing in helper file, but in every solution and method of creating helper files there is namespace, so, I had never try to remove that line.
But now I got the solution...
Thanks for all who helped me.
Shishil Patel
I guess you have syntaxis error in your helper.
anyways try to execute php artisan config:clear and then fix all errors.
I have done everything the same way and I haven't found any problem.
I trying to learn Laravel but I have a problem that I don't understand.
I get an error message when I want to run the controller.
I enter 3 lines of command on CMD
php artisan make:controller WelcomeController
php artisan make:controller AboutController
php artisan serve
Then, I establish the link between the controller and the route.
Route::get('about', 'AboutController#index');
And in the file AboutController.php I have
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AboutController extends Controller
{
public function index()
{
return view('about');
}
}
Normally it should work ? I looked a tuto on youtube https://www.youtube.com/watch?v=QASe8bXMMFA&t=56s
I have as error message => "include(C:\wamp64\www\testprojet\vendor\composer/../../app/Http/Controllers/Controller.php): failed to open stream: No such file or directory"
Do you have an idea please ?
Your error indicates that the Controller.php that your AboutController extends.
Is there a Controller.php file in C:\wamp64\www\testprojet\app\Http\Controllers?
I suspect there isn't, and if needed you can create it using the current Controller.php file in the Laravel repository.
I'm unsure why this is the case, but suspect it may be due to a step being missing when setting your project up... What steps did you follow to get Laravel up and running for your project?
The error might be due to I have faced the same error because I have moved the Controller.php file from http/controllers folder to other place by mistake.
you should check that Controller.php file exists in the app/http/controllers.
I can access the list of files in a directory in Laravel using this:
use File;
....
$files = File::files($path);
However, I get this error in lumen:
Class 'File' not found
Any idea how I can access list of files in a folder in lumen.
File is only avaiable in Laravel by default. Although you can still used it on Lumen Framework by doing the following.
Enable the facade in boostrap/app.php by uncommenting the following code.
$app->withFacades();
After that, you will be able to access the File class in any of your controller by adding it as:
use Illuminate\Http\File;
or you can use the Facade Class.
use Illuminate\Support\Facades\File;
Please do a composer dump-autoload to update autoload.
I'm sure that the solution to this problem is staring me right in the face, but unfortunately I can't seem to figure it out. I'm trying to add a route to my laravel 5.1 installation, and I'm getting the below error...
ReflectionException in Container.php line 737:
Class App\Http\Controllers\Tools\DashBoardController does not exist
I first edited the routes file to include the below...
(file: app\Http\routes.php)
Route::get('dashboard', 'Tools\DashBoard#index');
Then I created the "Tools" folder and "DashBoardController.php" file, and have it setup to look somewhat like the below...
(file: app\Http\Controllers\Tools\DashBoardController.php)
namespace App\Http\Controllers\Tools\DashBoard;
//...etc...//
class DashBoardController extends Controller { /* ..etc.. */ }
Is this all I have to do? I read that you could run "composer dumpautoload" in the terminal but unfortunately that didn't help.
I'm on a localhost XAMPP install w/PHP7 on Win7, if that's useful. Any help is greatly appreciated!
Your namespace declaration should look like namespace App\Http\Controllers\Tools and should not contain the filename or name of your class. Then you need to change your route to point to the name of your class Route::get('dashboard', 'Tools\DashBoardController#index');.
The way autoloaders and namespaces work in PHP and specifically in Laravel is that the namespace must reflect the directory structure and the class name must match its filename.
If you will have multiple routes using controllers from the same namespace, you will probably benefit from implementing route group namespaces.
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.