Am using https://spatie.be/docs/laravel-backup/v7/introduction for backup and I tried to backup database using php artisan backup:run but i got these errors:
Backup failed because The dump process failed with exitcode 2 : Misuse of shell builtins : sh: 1: /opt/lampp/bin/mysql/mysqldump: not found
Sending notification failed
Backup failed because: The dump process failed with exitcode 2 : Misuse of shell builtins : sh: 1: /opt/lampp/bin/mysql/mysqldump: not found
.
Swift_RfcComplianceException
Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
at vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php:355
351▕ */
352▕ private function assertValidAddress($address)
353▕ {
354▕ if (!$this->emailValidator->isValid($address, new RFCValidation())) {
➜ 355▕ throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.');
356▕ }
357▕ }
358▕ }
359▕
+38 vendor frames
39 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
What should I do ?
I think the problem is in database.php in this code
'dump' => [
'dump_binary_path' => '/opt/lampp/bin/mysql', // only the path, so without `mysqldump` or `pg_dump`
'use_single_transaction',
'timeout' => 60 * 5, // 5 minute timeout
],
Where can I find mysqldump on lampp Ubuntu ?
PS: I am using laravel 8 on Ubuntu
Laravel doesn't have official command to take db backup which you mentioned
You must use following package
https://spatie.be/docs/laravel-backup/v7/installation-and-setup
To know laravel default php artisan commands .You can run following command to defualt commands available in php artisan.
php artisan
The result will show like below
Laravel Framework 8.42.1
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
clear-compiled Remove the compiled class file
db Start a new database CLI session
down Put the application into maintenance / demo mode
env Display the current framework environment
help Display help for a command
inspire Display an inspiring quote
list List commands
migrate Run the database migrations
optimize Cache the framework bootstrap files
serve Serve the application on the PHP development server
test Run the application tests
tinker Interact with your application
ui Swap the front-end scaffolding for the application
up Bring the application out of maintenance mode
auth
auth:clear-resets Flush expired password reset tokens
cache
cache:clear Flush the application cache
cache:forget Remove an item from the cache
cache:table Create a migration for the cache database table
config
config:cache Create a cache file for faster configuration loading
config:clear Remove the configuration cache file
db
db:seed Seed the database with records
db:wipe Drop all tables, views, and types
event
event:cache Discover and cache the application's events and listeners
event:clear Clear all cached events and listeners
event:generate Generate the missing events and listeners based on registration
event:list List the application's events and listeners
key
key:generate Set the application key
make
make:cast Create a new custom Eloquent cast class
make:channel Create a new channel class
make:command Create a new Artisan command
make:component Create a new view component class
make:controller Create a new controller class
make:event Create a new event class
make:exception Create a new custom exception class
make:factory Create a new model factory
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:notification Create a new notification class
make:observer Create a new observer class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:resource Create a new resource
make:rule Create a new validation rule
make:seeder Create a new seeder class
make:test Create a new test class
migrate
migrate:fresh Drop all tables and re-run all migrations
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
notifications
notifications:table Create a migration for the notifications table
optimize
optimize:clear Remove the cached bootstrap files
package
package:discover Rebuild the cached package manifest
queue
queue:batches-table Create a migration for the batches database table
queue:clear Delete all of the jobs from the specified queue
queue:failed List all of the failed queue jobs
queue:failed-table Create a migration for the failed queue jobs database table
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:prune-batches Prune stale entries from the batches database
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:retry-batch Retry the failed jobs for a batch
queue:table Create a migration for the queue jobs database table
queue:work Start processing jobs on the queue as a daemon
route
route:cache Create a route cache file for faster route registration
route:clear Remove the route cache file
route:list List all registered routes
sail
sail:install Install Laravel Sail's default Docker Compose file
sail:publish Publish the Laravel Sail Docker files
schedule
schedule:list List the scheduled commands
schedule:run Run the scheduled commands
schedule:test Run a scheduled command
schedule:work Start the schedule worker
schema
schema:dump Dump the given database schema
session
session:table Create a migration for the session database table
storage
storage:link Create the symbolic links configured for the application
stub
stub:publish Publish all stubs that are available for customization
ui
ui:auth Scaffold basic login and registration views and routes
ui:controllers Scaffold the authentication controllers
vendor
vendor:publish Publish any publishable assets from vendor packages
view
view:cache Compile all of the application's Blade templates
view:clear Clear all compiled view files
Updated:
Look like the issue is with dump_binary_path
so it should be 'dump_binary_path'=>'/opt/lampp/bin' in config file
Related
I am trying to create a new rule (php artisan make:rule Captcha) from the cmd and I get the error: Command "make:rule" is not defined
Did you mean one of these?
make:auth
make:command
make:controller
make:event
make:job
make:listener
make:mail
make:middleware
make:migration
make:model
make:notification
make:policy
make:provider
make:request
make:seeder
make:test
In addition, if I execute the php artisan command, the MAKE section only shows:
make:auth Scaffold basic login and registration views and routes
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:notification Create a new notification class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:seeder Create a new seeder class
make:test Create a new test class
Any solution for the php artisan make:rule Captcha command to work.
I am using Laravel version 5.4.36
Thank you.
Artisan make:rule command released in laravel 5.5, you have to upgrade to that version or higher, but be careful, there can be any other changes. Read laravel docs about upgrade from 5.4 to 5.5 https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0
php artisan make:rule was commited to the code base on 25 Jun 2017.
It seems it's available in Laravel 5.5+ as it started to be available with the L5.5 docs.
I have an old Symfony 3.4 app (https://github.com/opencfp/opencfp) that needs to have Doctrine added to it so I can replace an existing auth/acl solution with Symfony Guard and then get moving towards upgrading towards Symfony 5. I've installed doctrine/doctrine-bundle and can see that the commands are in the vendor directory but when I run bin/console none of the doctrine commands show up.
Here's what I found when I searched my vendor directory for Doctrine console commands.
doctrine/doctrine-bundle/Resources/config/dbal.xml
87: <tag name="console.command" command="doctrine:database:create" />
93: <tag name="console.command" command="doctrine:database:drop" />
97: <tag name="console.command" command="doctrine:database:import" />
doctrine/doctrine-bundle/Command/Proxy/ImportDoctrineCommand.php
23: ->setName('doctrine:database:import')
doctrine/doctrine-bundle/Command/DropDatabaseDoctrineCommand.php
29: ->setName('doctrine:database:drop')
doctrine/doctrine-bundle/Command/CreateDatabaseDoctrineCommand.php
25: ->setName('doctrine:database:create')
When I run bin/console I don't see any of the commands in the doctrine namespace
Symfony 3.4.35 (kernel: OpenCFP, env: development, debug: true)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "development"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Displays information about the current project
help Displays help for a command
list Lists commands
assets
assets:install Installs bundles web assets under a public directory
cache
cache:clear Clears the cache
cache:pool:clear Clears cache pools
cache:pool:prune Prunes cache pools
cache:warmup Warms up an empty cache
config
config:dump-reference Dumps the default configuration for an extension
debug
debug:autowiring Lists classes/interfaces you can use for autowiring
debug:config Dumps the current configuration for an extension
debug:container Displays current services for an application
debug:event-dispatcher Displays configured listeners for an application
debug:form Displays form type information
debug:router Displays current routes for an application
debug:swiftmailer Displays current mailers for an application
debug:translation Displays translation messages information
debug:twig Shows a list of twig functions, filters, globals and tests
eloquent
eloquent:make:seeder Create a new seeder class
eloquent:migrate Executes a migration.
eloquent:migrate:fresh Drop all tables and re-run all migrations.
eloquent:migrate:install Creates the migration repository.
eloquent:migrate:make Creates a new migration file
eloquent:migrate:refresh Reset and re-run all migrations
eloquent:migrate:reset Rollback all database migrations
eloquent:migrate:rollback Rollback the last database migration
eloquent:migrate:status Show the status of each migration
eloquent:seed Seed the database with records
lint
lint:twig Lints a template and outputs encountered errors
lint:xliff Lints a XLIFF file and outputs encountered errors
lint:yaml Lints a file and outputs encountered errors
router
router:match Helps debug routes by simulating a path info match
server
server:log Starts a log server that displays logs in real time
server:run Runs a local web server
server:start Starts a local web server in the background
server:status Outputs the status of the local web server
server:stop Stops the local web server that was started with the server:start command
swiftmailer
swiftmailer:email:send Send simple email message
swiftmailer:spool:send Sends emails from the spool
translation
translation:update Updates the translation file
user
user:create Creates a new user
user:demote Demote an existing user from a role
user:promote Promote an existing user to a role
I do have some custom commands in there as well.
Any help is greatly appreciated.
From what I gather from vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php, a proper configuration for both the DBAL and the ORM are required to enable the commands:
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->adapter->loadServicesConfiguration($container);
if (! empty($config['dbal'])) {
$this->dbalLoad($config['dbal'], $container);
$this->loadMessengerServices($container);
}
if (empty($config['orm'])) {
return;
}
if (empty($config['dbal'])) {
throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.');
}
$this->ormLoad($config['orm'], $container);
}
The ormLoad and dbalLoad are responsible for registering the commands.
In this specific instance, Doctrine needs to be registered:
doctrine:
dbal:
url: mysql://db_user:db_password#127.0.0.1:3306/db_name
orm: ~
The above goes at the end of resources/config/config.yml, or any other file of that folder. Also, you'd need to make the proper adjustments.
doctrine
doctrine:cache:clear-collection-region Clear a second-level cache collection region
doctrine:cache:clear-entity-region Clear a second-level cache entity region
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-query-region Clear a second-level cache query region
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:cache:contains Check if a cache entry exists
doctrine:cache:delete Delete a cache entry
doctrine:cache:flush [doctrine:cache:clear] Flush a given cache
doctrine:cache:stats Get stats on a given cache provider
doctrine:database:create Creates the configured database
doctrine:database:drop Drops the configured database
doctrine:database:import Import SQL file(s) directly to Database.
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment
doctrine:generate:entities [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
doctrine:mapping:convert [orm:convert:mapping] Convert mapping information between supported formats
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info
doctrine:query:dql Executes arbitrary DQL directly from the command line
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate Validate the mapping files
How can you retry all failed jobs in Laravel Horizon? There appears to be no "Retry All" button and the artisan command doesn't work as the failed jobs aren't stored in a table.
The queue:retry command accepts all in place of an individual job ID:
php artisan queue:retry all
This will push all of the failed jobs back onto your redis queue for retry:
The failed job [44] has been pushed back onto the queue!
The failed job [43] has been pushed back onto the queue!
...
If you didn't create the failed logs table according to the installation guide with:
php artisan queue:failed-table
php artisan migrate
Then you may be up a creek. Maybe try interacting with redis manually and trying to access the list of failed jobs directly (assuming the failed jobs entries haven't been wiped - looks like they default to persisting in redis for a week, based on the config settings in config/horizon.php).
as the failed jobs aren't stored in a table
Actually, you should create that table. From the Laravel Horizon documentation:
You should also create the failed_jobs table which Laravel will use to
store any failed queue jobs:
php artisan queue:failed-table
php artisan migrate
Then, to retry failed jobs:
Retrying Failed Jobs
To view all of your failed jobs that have been inserted into your
failed_jobs database table, you may use the queue:failed Artisan
command:
php artisan queue:failed
The queue:failed command will list the job ID, connection, queue,
and failure time. The job ID may be used to retry the failed job. For
instance, to retry a failed job that has an ID of 5, issue the
following command:
php artisan queue:retry 5
I am looking to make a generic appointment system in Laravel and I want to use that in my other projects.
Is there any way to achieve by creating custom commands? For example, php artisan make:auth creates a complete login, register, forgot and reset password functionality.
I want to do the same, like php artisan appoitment : make and it should create the models, controllers and database migrations in that Laravel installation
php artisan make:command {command name}. You can see {command name} file in app/console/commands directory.
change $signature to appoitment:make.
add your command class to app/console/Kernel.php commands list.
for example:
php artisan make:command AppoitmentCommand
In Kernel.php : $commands = [
AppoitmentCommand::class
];
php artisan //you can see all commands
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