iIlluminate/mail not available in artisan - laravel

I use Lumen7 (based on Laravel7) as framework for my projekt. I tried to install the mailer, but it doesn't work.
I did the following steps:
Installed illuminate/mail via composer require illuminate/mail:7
Added the following to bootstrap/app.php
$app->register(Illuminate\Mail\MailServiceProvider::class);
$app->configure('mail');
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class);
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
Copied the mail.php from
https://github.com/laravel/laravel/blob/master/config/mail.php to
config/mail.php
Added the following to my .env
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello#example.com
MAIL_FROM_NAME="Example app"
When I try to generate my mailable via php artisan make:mail MyMailable, then I get the following error: Command "make:mail" is not defined.
When I use php artisan, then I don't see mail in the command list of make, just the following make commands:
make
make:migration Create a new migration file
make:seeder Create a new seeder class
I have no idea what the issue is, hopefully someone can help me.

I think I've found a way to achieve this. Apparently Lumen needs another package installed to have all the Laravel methods. Simply add the composer package:
composer require flipbox/lumen-generator
And enable it in your bootstrap/app.php file:
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
Afterwards your "php artisan" should return way more methods, also for "make:mail".

Related

Cannot locate class of installed package

I'm writing a laravel package which contains spatie/laravel-sitemap.
I already included several external packages and I didn't encountered any issues, but for some reason I'm not able to integrate this one.
What I did is the usual:
composer require spatie/laravel-sitemap
Then I have created a Console command that have as handle method the following content:
public function handle()
{
SitemapGenerator::create(config('app.url'))
->configureCrawler(function (Crawler $crawler) {
$crawler->ignoreRobots();
})
->writeToFile(public_path('sitemap.xml'));
$this->line('<info>Sitemap generated');
}
when I execute the command registered as:
php artisan myapp:sitemap
I get:
Class "Spatie\Sitemap\SitemapGenerator" not found
The reference imported are:
use Spatie\Crawler\Crawler;
use Spatie\Sitemap\SitemapGenerator;
I also tried composer update and composer dump-autoload, same problem.
Any help?
register package class in providers array in config/app.php
Spatie\Sitemap\SitemapServiceProvider;
in the bottom of app.php file
i hope it was useful.
you can publish package using this.
php artisan vendor:publish --provider="Spatie\Sitemap\SitemapServiceProvider" --tag=sitemap-config
then
composer dump-autoload
for more details please check the document https://github.com/spatie/laravel-sitemap under Configuration

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

Lumen mail driver is null issue

I am following this link https://lumen.laravel.com/docs/5.7/mail
here is my bootstrap/app.php code
$app->withFacades();
$app->withEloquent();
$app->register(\Illuminate\Mail\MailServiceProvider::class);
$app->configure('services');
$app->configure('mail');
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
I run below code as well
composer require illuminate/mail
composer update
Here is my .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abc#gmail.com
MAIL_PASSWORD=Abc#12345
MAIL_ENCRYPTION=tls
I installed fresh lumen and i am sure i did not missed anything.
I am getting this error
Unable to resolve NULL driver for [Illuminate\Mail\TransportManager].
The problem. you need to add config file for mail. (config/mail.php)
Just Copy Laravel mail.php config file to lumen root_dir/config/mail.php
Reference THIS LINK

How to integrate Admin Lte theme in Laravel 5.4

Need Help to integrate Admin Lte theme in la ravel 5.4 , i try to integrate it but it show black pages.
Download laravel project folder by using:
composer create-project --prefer-dist laravel/laravel laravelLTE
Create database named :laravel and make database related changes in .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=null
Goto the folder path
/var/www/html$ cd laravelLTE
To run all of your outstanding migrations, execute the migrate Artisan command:
/var/www/html/laravelLTE$ php artisan migrate
In case of string error make changes in following page :
/var/www/html/laravel/app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Inorder to install Admin Lte theme hit following commands in your terminal:
composer require "acacha/admin-lte-template-laravel:4.*"
composer update
To register the Service Provider edit the file
config/app.php
And add following line to providers array:
Acacha\AdminLTETemplateLaravel\Providers\AdminLTETemplateServiceProvider::class,
To Register Alias edit the file
config/app.php
And add following line to alias array:
'AdminLTE' => Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::class,
Get configuration file in your application from vendor package file.
/var/www/html/laravelLTE$ php artisan vendor:publish --tag=adminlte –force
/var/www/html/laravelLTE$ php artisan serve
thank you
I hope this will help you to integrate adminLTE theme

Laravel 5.2.2 and Entrust error call to undefined method

When I am using latest Laravel 5.2.2 and Entrust ("zizaco/entrust": "5.2.x-dev") I face this error and not sure how to solve this:
Call to undefined method Zizaco\Entrust\EntrustServiceProvider::hasRole()
I tested this code on HomeController.php
use Entrust;
class HomeController extends Controller
{
public function index()
{
if (Entrust::hasRole('admin')) {
echo "string";
}
return view('home');
}
}
This is my config/app.php service provider
Zizaco\Entrust\EntrustServiceProvider::class
config/app.php facade alias
'Entrust' => Zizaco\Entrust\EntrustFacade::class
I also already generate the model needed
Did I miss something here?
I have same issue, here are the steps I have taken to solve the issue
In your .env file change to cache array
CACHE_DRIVER=array
and dont forget to run
php artisan config:cache
It seems all the steps is correct, and I just need to clear the cache with php artisan config:cache
And if you face an error like below
BadMethodCallException in vendor\laravel\framework\src\Illuminate\Cache\Repository.php line 380:
This cache store does not support tagging.
You need to change in .env this line to array
CACHE_DRIVER=array
Try this:
Open environment file of your laravel change CACHE_DRIVER=file to CACHE_DRIVER=array and save.
Now try your CLI command.
Laravel drivers does not support tagging. To solve this, go to your .env file and change
Cache_driver=file
to
Cache_driver=array
and run
php artisan config:cache

Resources