Attached Image shows exact my problem:
Given below is my app.php where providers array is defined.****This is laravel 4.2.
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'FanzoopMain\Theme\Provider\ThemeServiceProvider',
'Creolab\LaravelModules\ServiceProvider',
'FanzoopMain\Menu\MenuServiceProvider',
'FanzoopMain\Image\ImageServiceProvider',
'FanzoopMain\Hook\HookServiceProvider',
/**
* App base
*/
'App\Providers\ConfigurationServiceProvider',
'App\Providers\AddonServiceProvider',
'App\Providers\PhotoServiceProvider',
'App\Providers\AdmincpServiceProvider',
'App\Providers\ThemeManagerServiceProvider',
'App\Providers\NotificationServiceProvider',
'App\Providers\MentionServiceProvider',
'App\Providers\HashtagServiceProvider',
'App\Providers\MenuServiceProvider',
'App\Providers\EmoticonServiceProvider',
'App\Providers\ConnectionServiceProvider',
'App\Providers\PostServiceProvider',
'Artdarek\OAuth\OAuthServiceProvider',
'Maatwebsite\Excel\ExcelServiceProvider',
),
/*
|--------------------------------------------------------------------------
| Service Provider Manifest
|--------------------------------------------------------------------------
|
| The service provider manifest is used by Laravel to lazy load service
| providers which are not needed for each request, as well to keep a
| list of all of the services. Here, you may set its storage spot.
|
*/
'manifest' => storage_path().'/meta',
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'SSH' => 'Illuminate\Support\Facades\SSH',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'OAuth' => 'Artdarek\OAuth\Facade\OAuth',
'Addon' => 'App\Facades\Addon',
'ThemeManager' => 'App\Facades\ThemeManager',
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
),
This is my another file, named ConfigurationServiceProvider.php, where I am using the error occuring code.
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Providers\ConfigurationServiceProvider;
/**
* Configuration service provider
*
* #author : Tiamiyu waliu kola
* #webiste: procrea8.com
*/
class ConfigurationServiceProvider extends ServiceProvider
{
public function register(){
}
public function boot(){
if (\Config::get('system.installed')) {
$repository = app('App\Repositories\ConfigurationRepository');
foreach($repository->getAll() as $configuration) {
\Config::set($configuration['slug'], $configuration['value']);
}
/**
* set image configuration
*/
\Config::set('image::max-size', \Config::get('image-max-size'));
\Config::set('image::save-original', \Config::get('keep-original-image'));
\Config::set('image::allow-animated-gif', \Config::get('allow-animated-gif'));
\Config::set('image::ext-allowed', \Config::get('image-allow-type', 'gif,png,jpg'));
/**Assets***/
\Config::set('theme::minifyAssets', \Config::get('minify-assets'));
}
}
}
Try
composer dump-autoload
Or
php artisan dump-autoload
Make sure you have registered your providers directory on composer.json
"autoload": {
"classmap": [
"app/providers"
]
},
Tty this steps
Temporary remove your providers and aliases
Type command composer update
Then add this providers and aliases
Because when you update composer he try to find this classes before adding in your project, After updating your composer add this classes
Related
Problem
Love L5. But last 24h been a nightmare. None of my 3rd party service providers (SP) are loading. I did a clean install of L5 and tried adding the SPs but still not working.
The SPs install as they should in the vendor folder when running composer update. But when running the L5 I get the error message Class 'LaravelLocalization' not found
composer.json
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"twbs/bootstrap": "*",
"intervention/image": "*",
"laravelcollective/html": "*",
"barryvdh/laravel-debugbar": "*",
"davibennun/laravel-push-notification": "dev-laravel5",
"mcamara/laravel-localization": "1.1.*",
"tijsverkoyen/css-to-inline-styles": "1.5.5",
"league/csv": "*"
},
app.config
providers
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*
* 3rd Party Service Providers...
*/
Barryvdh\Debugbar\ServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider::class,
Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class
aliases
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class,
'Image' => Intervention\Image\Facades\Image::class,
'PushNotification' => Davibennun\LaravelPushNotification\Facades\PushNotification::class,
'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class
Things I tried
Laravel 5.2 Service provider not booting
php artisan clear-compiled
composer dump-autoload
php artisan optimize
Laravel - Composer unable to find the service provider class
composer clear
I've also scorched the internet but come up dry.. :( https://laracasts.com/discuss/channels/general-discussion/laravel-5-package-serviceprovider-cant-be-found)
Ideas?
Any ideas how to overcome greatly appreciated. Cannot run the app now and lost a day of work.. :/
UPDATE
The autoload_files.php in vendor/composer does NOT contain some of the frameworks. barryvdh/laravel-debugbar is part of it (does not get loaded) but for instance Mcamara\LaravelLocalization is NOT part of the autoload_files.
But the Mcamara\LaravelLocalization is part of the autoload_static.php under $prefixesPsr0 - if that helps?
autoload_files.php (in /vendor/composer/)
return array(
'1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'f18cc91337d49233e5754e93f3ed9ec3' => $vendorDir . '/laravelcollective/html/src/helpers.php',
'4a1f389d6ce373bda9e57857d3b61c84' => $vendorDir . '/barryvdh/laravel-debugbar/src/helpers.php',
);
SOLUTION
A THIRD clean install of L5 where I add in the SPs ONE by ONE seems to work. Just happy to be back on track. Cannot thank everyone enough - big shout out to #MikeBarwick who provided good guidance throughout - THANKS! :)
Try this:
composer dump-autoload --optimize
It's because your are missing class in providers file
$this->app->register(\L5Swagger\L5SwaggerServiceProvider::class);
Paste it under register
hope so it will start working.
I have follow the upgrade guide but I can't manage to make the Authorization work.
AuthServiceProvider
<?php
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* #var array
*/
/*protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];*/
protected $policies = [
Request::class => AnalysisPolicy::class,
];
/**
* Register any application authentication / authorization services.
*
* #param \Illuminate\Contracts\Auth\Access\Gate $gate
* #return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
//
}
}
Analysis policy
<?php
namespace App\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\User;
use App\Request;
class AnalysisPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* #return void
*/
public function __construct()
{
//
}
public function view(Request $analysis){
return true;
}
//
}
Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
TestController
public function showTest()
{
$analysis= Request::find(1);
return view('test', ['analysis' => $analysis]);
}
Test.blade.php
Test page
#can('view', $analysis)
Hello world
#endcan
config\app
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Html\HtmlServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
I always get Class 'Gate' not found. I have laravel 5.1.23. I have tried to run composer update and artisan clear-compiled but nothing worked.
Here is my solution:
in
\vendor\laravel\framework\src\illuminate\Auth\AuthServiceProvider.php
update the provider
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Auth/AuthServiceProvider.php
I want to show a list of my posts table rows via datatables jquery plugin with laravel version 5.1 via yajra-laravel-datatables.
For that I do all instructions described in this Quick Start Giude in my project.
this is my Route only for get all data that are Necessary for dataTable:
Route::get('postsData', 'postController#testData');
and this is complete postController php file :
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use yajra\Datatables\Datatables;
class postController extends Controller
{
public function index ()
{
$allPosts = Post::all();
return \View::make('admin.pages.posts')->with('posts', $allPosts);
}
public function create ()
{
return \View::make('admin.pages.post_create');
}
public function store (Request $request)
{
$data = Input::all();
$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);
$validator = \Validator::make($data, $rules);
if ($validator->fails()) {
return \Redirect::to('/admin/posts/create')
->withErrors($validator)
->withInput();
} else {
$post = new Post();
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();
return \Redirect::to('/admin/posts');
}
}
public function show ($id)
{
$post = Post::find($id);
return \View::make('admin.pages.show_post')->with('post', $post);
}
public function edit ($id)
{
$post = Post::find($id);
return \View::make('admin.pages.edit_post')->with('post', $post);
}
public function update (Request $request, $id)
{
$data = Input::all();
$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);
$validator = \Validator::make($data, $rules);
if ($validator->fails()) {
return \Redirect::to('post/create')
->withErrors($validator)
->withInput();
} else {
$post = Post::find($id);
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();
return \Redirect::to('admin/posts');
}
}
public function destroy ($id)
{
$post = Post::find($id);
$post->delete();
return Redirect::to('admin/posts');
}
public function postsAll(){
return View::make('admin.pages.postsAll');
}
public function testData(){
return Datatables::of(Post::select('*'))->make(true);
}
}
also I add Service Provider and Facade to config/app.php :
return [
'debug' => env('APP_DEBUG', false),
'url' => 'http://localhost',
'timezone' => 'UTC',
'locale' => 'en',
'fallback_locale' => 'en',
'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC',
'log' => 'single',
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
yajra\Datatables\DatatablesServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Datatables' => yajra\Datatables\Datatables::class,
],
];
And this is Structure of yajra in vendor composer folder:
But when I open postsData path in browser this error shown:
ReflectionException in Container.php line 737:
Class datatables does not exist
What is Problem?
I found the solution after hours of googling and try different ways :
1.first rename your project to a new name.
2.use composer update
3.run php artisan config:cache
4.and run php artisan cache:clear
and try your Code again.
Try change in your controller
Remove:
use yajra\Datatables\Datatables;
Add
use Datatables;
config/app.php
You must have in providers:
yajra\Datatables\DatatablesServiceProvider::class,
and must have in aliases:
'Datatables' => yajra\Datatables\Datatables::class,
I manage to fix the same bugs.
In config/app.php
Yajra\DataTables\DatatablesServiceProvider::class,
Datatables' => Yajra\DataTables\Facades\Datatables::class,
Just make sure you capitalize 'T' in the '\DataTables\'
Ref. https://github.com/yajra/laravel-datatables/issues/986
same error has also happened if you don't have conf/datatables.php. try installing latest or above 7.x
composer require yajra/laravel-datatables-oracle
add these lines in config/app.php
Yajra\Datatables\DatatablesServiceProvider::class,
'Datatables' => Yajra\Datatables\Facades\Datatables::class,
php artisan config:cache
if you don't have file config/datables.conf. Try to paste these file there.
https://gist.github.com/hsali/1cab0d6c81020bf7bce043b65f94373a
Try this:
use Yajra\Datatables\Facades\Datatables;
I am using laravel 5, I want to get data from database but it throwing the below error:
FatalErrorException in LearnController.php line 38: Class 'App\Http\Controllers\DB' not found
I have been added the database details then also i am able get the title from ads_new table
Here's my code:
<?php
namespace App\Http\Controllers;
class LearnController extends Controller {
/*
|--------------------------------------------------------------------------
| Home Controller
|--------------------------------------------------------------------------
|
| This controller renders your application's "dashboard" for users that
| are authenticated. Of course, you are free to change or remove the
| controller as you wish. It is just here to get your app started!
|
*/
/**
* Create a new controller instance.
*
* #return void
*/
/**
* Show the application dashboard to the user.
*
* #return Response
*/
public function home()
{
$users = DB::table('ads_new')->get();
foreach ($users as $user)
{
var_dump($user->title);
}
}
}
database.php
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => 'mysql',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path().'/database.sqlite',
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'autoclick'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'autoclick'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'autoclick'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => false,
'default' => [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
],
],
];
The DB façade is in the global namespace, so you need to import it at the top of your controller:
<?php namespace App\Http\Controllers;
use DB;
Have a read up on namespaces in PHP: http://php.net/manual/en/language.namespaces.php
Try this solution:
From Matt Burrow comment
Add a \ before DB like so; \DB or add use \DB; at the top.
So it should be like :
class LearnController extends Controller {
public function home()
{
$users = \DB::table('ads_new')->get();
foreach ($users as $user)
{
var_dump($user->title);
}
}
}
I'm following a tutorial from Code Forest an when using php artisan db:seed, I get this error:
PHP Fatal Error: Class 'Sentry' not found in /var/www/app/database/seeds/SentrySeeder.php on line 13
here is SentrySeeder.php :
<?php
use App\Models\User;
class SentrySeeder extends Seeder {
public function run()
{
DB::table('users')->delete();
DB::table('groups')->delete();
DB::table('users_groups')->delete();
Sentry::getUserProvider()->create(array(
'email' => 'admin#admin.com',
'password' => "admin",
'first_name' => 'John',
'last_name' => 'McClane',
'activated' => 1,
));
Sentry::getGroupProvider()->create(array(
'name' => 'Admin',
'permissions' => array('admin' => 1),
));
// Assign user permissions
$adminUser = Sentry::getUserProvider()->findByLogin('admin#admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Admin');
$adminUser->addGroup($adminGroup);
}
}
And here is User model
Sentry has been added to apps under providers
What Am i missing?
Have you added the Facade for Sentry?
add
'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry',
to the array of facades in config/app.php
Add 'Cartalyst\Sentry\SentryServiceProvider' to the list of service providers in app/config/app.php
I had to add both in app/config/app.php file:
1.
'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry',
to the: 'aliases' => array(
AND
2.
Cartalyst\Sentry\SentryServiceProvider,
to the: 'providers' => array(