I am using laravel 5.4 and php version is 5.6.
I am getting error "Class 'Datatables' not found". I am following standard procedure. I have installed datatable using composer by following command:
composer require yajra/laravel-datatables-oracle:"~7.0"
I added these two lines in config->app file in service provider and aliases:
Yajra\DataTables\DataTablesServiceProvider::class,
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
then publish package :
php artisan vendor:publish --provider=Yajra\DataTables\DataTablesServiceProvider
I am using raw query here is my controller code :
function allvendor(){
$sql="my query";
$results=DB::table(DB::raw("($sql)"));
return Datatables::of($results)->make(true);
}
It's a typo. You set alias as DataTables but returned is Datatables.
Related
I am using Laravel 7 and Jensseger's MongoDB package.
Everything works fine, except for this:
When I issue php artisan view:clear, I get MongoDB\Driver\Manager Not Found error.
I already have installed the latest version of MongoDB module for php 7.4 and everything else works fine. Meanwhile, I am using a dockerized environment. So, I am totally clueless why this is happening when I try to clear cached views.
This is my ViewServiceProvider file:
class ViewServiceProvider extends ServiceProvider
{
public function register()
{
}
public function boot(HeaderRepository $repository)
{
$header = $repository->getHeader();
View::composer('errors::*', function($view) use($header){
$view->with([
'header' => $header,
]);
});
}
}
My purpose is to create a customized 404 error page, but the header has to be fetched from MongoDB and shared between customized error pages. That's why I'm using view composers. Any other solution is welcome as well.
I suppose, you enter command php artisan view:clear from a local console.
You have choice:
Install mongo drive to your local interpreter
Use artisan from docker container eg docker exec {PHP_CONTAINER} php artisan view:clear
I installed Larecipe in the project and he can't load correctly. When i see "/docs/1.0/overview", get errors in console and layout can't be load.
Uncaught ReferenceError: CreateLarecipe is not defined
Uncaught ReferenceError: LaRecipe is not defined
I made package updates and unfortunately it did not help.
Laravel Framework 5.7.28
"binarytorch/larecipe": "^2.1",
This may be an issue with the LaRecipe service provider not being registered (or auto-registered).
Add the service provider to the providers array in config/app.php:
'providers' => [
// Other Service Providers
BinaryTorch\LaRecipe\LaRecipeServiceProvider::class,
],
I experienced the same thing.
Try running both these Artisan commands:
php artisan larecipe:install
php artisan vendor:publish --tag=larecipe_assets --force
Please try this. I think you have to recreate boostrap/cache/compiled.php file.
php artisan optimize
I did a Laravel 5.5.43 installation this morning with the following Composer command:
composer create-project laravel/laravel project-name
I then ran the following command in the project folder to install Laravel Collective:
composer require "laravelcollective/html":"^5.4.0"
I then added the following under providers in config/app.php:
Collective\Html\HtmlServiceProvider::class,
And I added the following under aliases in config/app.php:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
After that, I wanted to create custom form components, so I ran the following Artisan command:
php artisan make:provider FormServiceProvider
And in that new provider file, I added the following line to the boot method:
Form::component('customText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]);
Lastly, I added the following to providers in config/app.php:
App\Providers\FormServiceProvider::class,
When I do that though and refresh the Laravel instance from the browser, I get the following error:
Class 'App\Providers\Form' not found
However, if I add the following at the top of the FormServiceProvider.php file, then it works:
use Collective\Html\FormFacade AS Form;
I understand the concept of namespaces and why that makes the Form::component method in the boot method in the file properly work, but what I don't get is why I need to add that use line to the file at all.
Isn't the 'Form' => Collective\Html\FormFacade::class, line in the aliases array in the app.php file supposed to do that for me so I don't need to add the use line to the FormServiceProvider.php at all? What am I missing / doing wrong / not understanding?
Thank you.
I probably should just delete this question, but the simple answer was to add the following at the top of the FormServiceProvider.php file:
use Form;
Thanks.
Run below command:
php artisan config:cache
php artisan cache:clear
I use Lumen 1.0 for an API project.
I have already enable Eloquent by uncomment the following line in bootstrap/app.php file :
$app->withEloquent();
But when I want to create my first model with migration it fails :
php artisan make:model Book --migration
Error message :
[InvalidArgumentException]
Command "make:model" is not defined.
Did you mean one of these?
make:seeder
make:migration
Laravel doc about Eloquent (http://laravel.com/docs/5.1/eloquent#defining-models).
Lumen doc (http://lumen.laravel.com/docs/installation) doesn't include Eloquent doc because, it's not enable by default.
Do you have any ideas to avoid this error ?
Add details
php artisan --version
Displays :
Laravel Framework version Lumen (5.1.6) (Laravel Components 5.1.*)
You're seeing this error because Lumen doesn't come with make:model.
To see a list of all the artisan commands you have at your disposal just run php artisan.
That being said I did just find this package which I've added to a lumen installation and it seems to work fine https://github.com/webNeat/lumen-generators#installation
Hope this helps!
If you check all the available commands using php artisan list you will see that you don't have all the default ones offered by laravel. But you can get the most importants using the lumen-generator package (not to be confused with lumen-generators). It has the advantage of offering more commands than the other one mentioned.
To use it just install it using composer:
composer require flipbox/lumen-generator
Then enable it in your bootstrap/app.php file:
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
You will now be able to use all these new commands using artisan:
key:generate Set the application key
make:command Create a new Artisan command
make:controller Create a new controller class
make:event Create a new event class
make:job Create a new job class
make:listener Create a new event listener class
make:mail Create a new email class
make:middleware Create a new middleware class
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:policy Create a new policy class
make:provider Create a new service provider class
make:seeder Create a new seeder class
make:test Create a new test class
Just have a look at the official documentation: https://github.com/flipboxstudio/lumen-generator
Go to the project directory and add the generators package to your composer.json using the following command:
composer require wn/lumen-generators
Add following code segment to app/Providers/AppServiceProvider.php:
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Wn\Generators\CommandsServiceProvider');
}
}
Make sure that you have un-commented the following line in bootstrap/app.php to allow service providers on your project:
$app->register(App\Providers\AppServiceProvider::class);
Run php artisan list on the project directory (document root). Now you will see new items there.
just create your model file manually in the app directory
example
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model {
protected $table = ‘articles’;
protected $fillable = [
‘title’,
‘description’,
‘body’
];
}
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class); add this line into "bootstrap\app.php" and save this file then make the command.It will work.
there are some packages that can help you to have all of artisan command that you has on Laravel .
install below package to have more artisan command.
https://github.com/flipboxstudio/lumen-generator
I've found this page :
https://gist.github.com/rtconner/40b415073378da28b2bf
where it's shown a Service provider to be added in L5 in order to manage sftp connection driver in filesystem configs. Which is supposed to solve a issue.
Anyway once I executed via console:
php artisan make:provider SftpServiceProvider
And edited the SftpServiceProvider class as shown in the above webpage.
I went to config/app.php to add
'providers' => [
...
'App\Providers\SftpServiceProvider',
...
]
I tried a
composer dump-autoload --optimize (with and without the option)
But always I get a error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\Providers\SftpServiceProvider' not found
In fact, I cannot see in my vendor/composer/autoload_classmap.php
the line addressing to SftpServiceProvider
Also executing a
composer update #will not be ok.
Again the errors:
- Script php artisan clear-compiled handling the post-update-cmd event returned with an error
- [RuntimeException] Error Output: PHP Fatal error: Class 'App\Providers\SftpServiceProvider' not found
What do I miss in the ServiceProvider creation procedure?
Thanks