L5 service providers not loading - laravel

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.

Related

How to test sendgrid email with mailtrap for testing?

In my Laravel 7.6 app I use sendgrid for email sending with code in control like :
\Mail
::to($newContactUs->author_email)->
send(new SendgridMail('emails/contact_us_was_sent', $newContactUs->author_email, '', $subject, $additiveVars, $attachFiles));
with class in app/Mail/SendgridMail.php :
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Sichikawa\LaravelSendgridDriver\SendGrid;
use App\Settings;
use App\Http\Traits\funcsTrait;
class SendgridMail extends Mailable
{
use Queueable, SerializesModels;
use SendGrid;
use funcsTrait;
private $m_view_name;
private $m_to;
private $m_cc;
private $m_subject;
private $m_additiveVars;
private $m_attachFiles;
public function __construct( $view_name, $to= [], $cc= '', $subject= '', $additiveVars= [], $attachFiles= [] )
{
$this->m_view_name= $view_name;
$this->m_to= $to;
$this->m_cc= $cc;
$this->m_subject= $subject;
$all_emails_copy = \Config::get('app.all_emails_copy');
if ( empty($this->m_cc) and !empty($all_emails_copy)) {
$this->m_cc= $all_emails_copy;
}
$additiveVars['site_home_url'] = \URL::to('/');
$additiveVars['site_name'] = Settings::getValue('site_name');
$additiveVars['noreply_email'] = Settings::getValue('noreply_email');
$additiveVars['support_signature'] = Settings::getValue('support_signature');
$additiveVars['medium_slogan_img_url'] = config('app.url').config('app.medium_slogan_img_url');
$this->m_additiveVars= $additiveVars;
$this->m_attachFiles= $attachFiles;
}
/**
* Build the message.
*
* #return $this
*/
public function build( )
{
$mailObject= $this
->view( $this->m_view_name)
->subject($this->m_subject)
->to([$this->m_to])
->cc([$this->m_cc])
->with( $this->m_additiveVars )
->sendgrid( $this->m_additiveVars );
foreach( $this->m_attachFiles as $next_attach_file) {
if ( file_exists($next_attach_file) ) {
$mailObject->attach($next_attach_file);
}
}
return $mailObject;
}
}
and template resources/views/emails/contact_us_was_sent.blade.php:
...
<div class="wrapper">
#inject('viewFuncs', 'App\library\viewFuncs')
<h4 class="email_title">
Hello, {!! $to_user_name !!} !
</h4>
...
#include( 'emails.app_footer')
#include( 'emails.emails_style')
</div>
and it works for me now, but now with "Multiple Mail Drivers" I added mailtrap to my .env :
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=NNNNNNNN
MAIL_PASSWORD=NNNNNNNN
and I want to use mailtrap while testing the app using the same
template resources/views/emails/contact_us_was_sent.blade.php
and switching from mailtrap to sendgrid as easy as possible.
I tried something like :
\Mail::mailer('smtp')
->to($newContactUs->author_email)
->send( \Mail('emails/contact_us_was_sent', $newContactUs->author_email, '', $subject, $additiveVars, $attachFiles) );
But got error as \Mail does not support templates.
Are there something to use support templates for mail Method? Some wrapper?
Updated:
Priorly I worked with sendgrid and for this in file config/mail.php I
wrote all sendgrid parameters.
Now I want to write 2 emeil servers and fi=or this in .env I wrote:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=mailtrip_id
MAIL_PASSWORD=mailtrip_password
SENDGRID_HOST=smtp.sendgrid.net
SENDGRID_PORT=587
SENDGRID_ENCRYPTION=tls
SENDGRID_USERNAME=sendgrid_user
SENDGRID_PASSWORD=sendgrid_user_password
and I remade config/mail.php (I got a sample from):
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST'),
'port' => env('MAIL_PORT'),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'sendgrid' => [
'transport' => 'sendgrid',
'host' => env('SENDGRID_HOST', 'smtp.sendgrid.net'),
'port' => env('SENDGRID_PORT', 587),
'encryption' => env('SENDGRID_ENCRYPTION', 'tls'),
'username' => env('SENDGRID_USERNAME'),
'password' => env('SENDGRID_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
];
I am not sure that this config file is valid? Are mail config parameters are read from mailers array ?
Looks like default(mailtrip) mail config is used always. Is it invalid format ?
In my control Ido:
$email_mode= 'live';
// $email_mode= 'debug';
if( $email_mode== 'debug' ) {
\Log::info( '-10 Send to mailtrap ::' );
\Mail
::mailer('smtp')
->to('myemail#yahoo.com') // DEBUG
->send(new TestEmail); //
\Log::info( '-10 Send to mailtrap AFTER::' );
}
// sendgrid
if( $email_mode== 'live') {
\Log::info( '-11 Send to sendgrid ::' );
\Mail
::mailer('sendgrid')
->to('myemail#yahoo.com') // DEBUG
->send(new SendgridMail('emails/contact_us_was_sent', $newContactUs->author_email, '', $subject, $additiveVars, $attachFiles));
\Log::info( '-11 Send to sendgrid AFTER::' );
}
I check in logs that live flow is run but anyway I got email at mailtrap.
Thanks!
The short answer is you are using \Mail() which is a native php function
see: https://www.php.net/manual/en/function.mail.php and try to embed that in a laravel Mailer.
This is not how you should use it, this is really not advised.
Some more detail:
As you write mailables, already you should consider, the Mailable should not define the driver, so it's not encouraged to name it SendGridMailA.. see it as MailA send with Mail::mailer($mailDriver)
See:https://laravel.com/docs/7.x/mail#writing-mailables
Long answer, see this video, explains how to implement multiple mail drivers:
https://www.youtube.com/watch?v=HCONO0cwsoI
However it looks like you using it as a debug method. This is not why multiple mail drivers where introduced in laravel 7. It's more like you should use a different driver for bulk mails for example and for password resets...
That makes sense..
For debuging, it more usefull to make the default driver, depend on the APP_DEBUG configuration for example, or introduce an own ENV var, to toggle your production app in debug mode...
I found decision with modifying config/mail.php :
<?php
return [
'default' => env('MAIL_MAILER', 'sendgrid'),
'mailers' => [
'mailtrap' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST'),
'port' => env('MAIL_PORT'),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'sendgrid' => [
'transport' => 'smtp',
'host' => env('SENDGRID_HOST', 'smtp.sendgrid.net'),
'port' => env('SENDGRID_PORT', 587),
'encryption' => env('SENDGRID_ENCRYPTION', 'tls'),
'username' => env('SENDGRID_USERNAME'),
'password' => env('SENDGRID_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
and having 2 groups 'mailtrap' and 'sendgrid' in .env I wrote in control :
\Mail
::mailer(true ? 'sendgrid' : 'mailtrap')
->to($newContactUs->author_email)
->send(new SendgridMail(
'emails/contact_us_was_sent',
$newContactUs->author_email, '', $subject,
$additiveVars,
$attachFiles)
);

cakephp3 redis not configured properly

I am having a super hard time getting redis to be configured. It was working, but I upgraded my servers and composer updated- now I getting "redis is not configured correctly"
define('_CACHE_SERVER', '*********.cache.amazonaws.com:6379');
'_cake_core_' => [
'className' => 'Redis',
'servers'=> [ _CACHE_SERVER ],
'prefix' => 'mrg_cake_core_',
'serialize' => 'php',
'duration' => '+2 minutes',
],
I have written a blank php and connected to redis with just simple $redis = new Redis(); and got $redis->lastSave(); Seems like something changed in CAKE. Very confused.
Thank you ndm, I changed the config to:
define('_CACHE_SERVER', '************.cache.amazonaws.com');
'_cake_core_' => [
'className' => 'Redis',
'host' => _CACHE_SERVER,
'port' => 6379,
'prefix' => 'myapp_cake_core_',
'duration' => '+1 years',
'url' => env('CACHE_CAKECORE_URL', null),
],

Unable to connect with TLS encryption with Laravel 5.5 Swiftmailer

I am trying to send a mail using the Laravel inbuilt swift mailer but I keep getting the "Unable to connect with TLS encryption" error everytime.
Below is my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=myemailaddress
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
My config/mail.php file is below:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.office365.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myemailaddress'),
'name' => env('MAIL_FROM_NAME', ''),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','myemailaddress'),
'password' => env('MAIL_PASSWORD','mypassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
My controller where I initiate the mail sending is below:
if ($loan->save()) {
$name = staff::select('staff_name')->where('staff_id','=',$id)->first();
$data = array(
'Name' => $name,
'Amount' => $request->input('amount'),
'Tenor' => $request->input('tenor'),
'Purpose' => $request->input('purpose')
);
Mail::send('emails.loanrequest', $data, function($message){
$message->from('myaddress');
$message->to('myemailaddress');
$message->subject('New Loan Request');
});
}
Any help that would make this work would be appreciated. Thanks..
I had a similar problem trying to send an email using Laravel. Finally, I discovered that the problem was my antivirus (Avast in my case) software, blocking TLS calls for me. I write this because maybe it could be helpful to someone.
Apparently, It was my proxy server that was blocking my connection. Once I switched my connection, it worked..

service class not found error in laravel 4.2?

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

"Class datatables does not exist" Error when using "yajra" laravel datatables

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;

Resources