mysqldump -u[user] -p[pass] [db] > [file_path]
But what if you want to automate the process? Listing down the steps one by one:
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
php artisan make:command BackupDatabase
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class BackupDatabase extends Command
{
protected $signature = 'db:backup';
protected $description = 'Backup the database';
protected $process;
public function __construct()
{
parent::__construct();
$this->process = new Process(sprintf(
'mysqldump -u%s -p%s %s > %s',
config('database.connections.mysql.username'),
config('database.connections.mysql.password'),
config('database.connections.mysql.database'),
storage_path('app/backups/backup-' . time() . '.sql')
));
}
public function handle()
{
try {
$this->process->mustRun();
$this->info('The backup has been proceed successfully.');
} catch (ProcessFailedException $exception) {
$this->error('The backup process has been failed.');
}
}
}
$schedule->command('db:backup')->saturdays()->at('23:00');
* !.gitignore
That’s it you’ve now enabled weekly automated database backups
For more information and credits: https://pineco.de/scheduling-mysql-backups-with-laravel/
HTTPS_PROXY={http/https://}PROXY_USER:PROXY_PWD@PROXY:PROXY_PORT
(Combination of Proxy Address:Proxy Password@Proxy Address with port, don’t include http/https)
PROXY=xxxxxx (Proxy Name)
PROXY_PORT=xxxx (Proxy Port)
PROXY_USER=xxxxxxxxx (Proxy User Name)
PROXY_PWD=xxxxxxxxx (Proxy User Password)
PROXY_TYPE=CURLPROXY_HTTP
SSL_VERIFYPEER=true (true if SSL, else false)
Include actual values in HTTPS_Proxy
]]><?php /** * Laravel - A PHP Framework For Web Artisans * * @package Laravel * @author Taylor Otwell <taylorotwell@gmail.com> */ /* |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual | loading any of our classes later on. It feels nice to relax. | */ require __DIR__.'/bootstrap/autoload.php'; /* |-------------------------------------------------------------------------- | Turn On The Lights |-------------------------------------------------------------------------- | | We need to illuminate PHP development, so let us turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight our users. | */ $app = require_once __DIR__.'/bootstrap/app.php'; // set the public path to this directory $app->bind('path.public', function() { return __DIR__; }); /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response);
elixir.config.publicDir = ''; elixir.config.publicPath = ''; elixir(function(mix) { mix.sass('app.scss'); });
P.S.: Always use ‘url()’ function for every assets like images, css, js
You can also use, url(elixir(‘css/all.css’))
<script type="text/javascript"> tinymce.init({ selector: "textarea", // =========================================== // INCLUDE THE PLUGIN // =========================================== plugins: [ "advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste jbimages" ], // =========================================== // PUT PLUGIN'S BUTTON on the toolbar // =========================================== toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages", // =========================================== // SET RELATIVE_URLS to FALSE (This is required for images to display properly) // =========================================== relative_urls: false }); </script>
Just include “jbimages” in plugin and toolbar method to activate.
P.S.: Please keep the image upload path as writable.
]]>
Supervisor will automatically restart the queue if fails or stop working. To install Supervisor on Linux based system, use below command:
sudo apt-get install supervisor
[program:laravel-worker] user=user_name process_name=%(program_name)s_%(process_num)02d command=php application_path/artisan queue:listen --sleep=3 --tries=3 directory=application_path autostart=true autorestart=true numprocs=10 redirect_stderr=true stdout_logfile=application_path/storage/logs/worker.log
where,
user_name: Your machine user
application_path: Full path to your application
sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start laravel-worker:*
Step 1:
Set QUEUE_DRIVER=database in ‘.env‘ file
Step 2:
Navigate to ‘queue.php‘ file and check whether the table name and other settings for queue are present in database section
Step 3:
Run this command to migrate queue table in database
php artisan queue:table php artisan queue:failed-table php artisan migrate
You are ready for sending email through queue. Just replace Mail::send with Mail::queue or Mail::later
Final Steps:
Start and stop the following processes one by one to make Supervisor listen everytime (perform only if Supervisor doesn’t start listening automatically)
php artisan queue:listen php artisan queue:work --daemon
*Note:
1. Add ‘APP_URL‘ in .env file as per the accessible domain for application. If you’re using ‘url()‘ function in email which is queued, not adding ‘APP_URL‘ will generate a localhost URL.
2. While passing data to views when using Mail::queue or Mail::later the data isn’t accessible as expected. This happens when you’re passing an object or eloquent object and not as arrays. To make this work with queue you have to serialize the $eloquentObject first and later unserialize it in the view.
Mail::queue('emails.hello', serialize($data), function($message) { ... });
Add this on top of view file:
{{-- */unserialize($data);/* --}}]]>
$request = Request::create(url, 'GET'); $response = Route::dispatch($request); return $response;
$params = array( 'product_code' => 'GYU16R', 'qty' => '1', 'price' => 660, ); $request = Request::create(url, 'POST', $params); $response = app()->handle($request); return $response;
Note:
Always use full absolute path as url while creating request.
Eg: Use http://localhost/edit-user instead of /edit-user