Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home3/achieve/public_html/knowledgebase/wp-content/plugins/contact-form-7/includes/mail.php on line 109

Warning: The magic method GADWP_Manager::__wakeup() must have public visibility in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/gadwp.php on line 76

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 539

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 569

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 601

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 635

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 670

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 729

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home3/achieve/public_html/knowledgebase/wp-content/plugins/google-analytics-dashboard-for-wp/tools/gapi.php on line 769

Warning: Cannot modify header information - headers already sent by (output started at /home3/achieve/public_html/knowledgebase/wp-content/plugins/contact-form-7/includes/mail.php:109) in /home3/achieve/public_html/knowledgebase/wp-includes/feed-rss2.php on line 8
Laravel – Knowledge http://knowledge.achieveee.com Wed, 03 Apr 2019 14:59:24 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 http://knowledge.achieveee.com/wp-content/uploads/2016/05/cropped-favicon-32x32.png Laravel – Knowledge http://knowledge.achieveee.com 32 32 Scheduling MySQL backups with Laravel http://knowledge.achieveee.com/knowledge_base/scheduling-mysql-backups-with-laravel/ http://knowledge.achieveee.com/knowledge_base/scheduling-mysql-backups-with-laravel/#respond Wed, 03 Apr 2019 14:50:15 +0000 http://knowledge.achieveee.com/?post_type=knowledge_base&p=2591 To manually dump the database you can run the following one-liner code

mysqldump -u[user] -p[pass] [db] > [file_path]

But what if you want to automate the process? Listing down the steps one by one:

    1. Setup cron entry to your server
      * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
    2. Create a command BackupDatabase by running the following code:
      php artisan make:command BackupDatabase
    3. Navigate to app/Console/Commands/BackupDatabase.php and replace the code the following:
      <?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.');
              }
          }
      }
    4. Schedule the backup task, navigate to app/Console/Kernel.php and append the following line of code inside schedule method to run database backups every Saturday at 11PM. You can set the frequency as per your requirements
      $schedule->command('db:backup')->saturdays()->at('23:00');
    5. Create backups directory inside storage/app directory and place a .gitignore file inside backups directory with the following code
      *
      !.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/

]]>
http://knowledge.achieveee.com/knowledge_base/scheduling-mysql-backups-with-laravel/feed/ 0
Use Proxy Settings in Laravel .env http://knowledge.achieveee.com/knowledge_base/use-proxy-settings-in-laravel-env/ http://knowledge.achieveee.com/knowledge_base/use-proxy-settings-in-laravel-env/#respond Wed, 20 Sep 2017 10:08:12 +0000 http://knowledge.achieveee.com/?post_type=knowledge_base&p=2535 Use the following parameters in .env file:

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

]]>
http://knowledge.achieveee.com/knowledge_base/use-proxy-settings-in-laravel-env/feed/ 0
Change public directory in Laravel 5 http://knowledge.achieveee.com/knowledge_base/change-public-directory-in-laravel-5/ http://knowledge.achieveee.com/knowledge_base/change-public-directory-in-laravel-5/#respond Mon, 31 Jul 2017 13:52:11 +0000 http://knowledge.achieveee.com/?post_type=knowledge_base&p=2532 Just 3 steps are required to change the public directory:

  1. Cut all the files and folders in public directory and paste it to root folder
  2. Update the index.php as below:
    <?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);
  3. Update the elixir parameters in gulpfile.js:
    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’))

]]>
http://knowledge.achieveee.com/knowledge_base/change-public-directory-in-laravel-5/feed/ 0
Upload local image from TinyMCE http://knowledge.achieveee.com/knowledge_base/upload-local-image-from-tinymce/ http://knowledge.achieveee.com/knowledge_base/upload-local-image-from-tinymce/#respond Mon, 14 Nov 2016 14:16:13 +0000 http://knowledge.achieveee.com/?post_type=knowledge_base&p=2484 “jbimages” plugin does that magic of uploading your local image to server from TinyMCE. To setup the plugin follow the below steps:

  1. Download “jbimages” plugin from http://justboil.me/
  2. Unzip it into TinyMCE’s plugins folder
  3. Edit config.php file found in plugins/jbimages
  4. Set $config[‘img_path’] as per your requirement. Eg: ‘images/blog’
  5. Activate jbplugins in script by following code. Don’t forget to set relative_urls: false
    <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.

 

]]>
http://knowledge.achieveee.com/knowledge_base/upload-local-image-from-tinymce/feed/ 0
Create Queue Listener in Laravel 5 http://knowledge.achieveee.com/knowledge_base/create-queue-listener-in-laravel-5/ http://knowledge.achieveee.com/knowledge_base/create-queue-listener-in-laravel-5/#respond Tue, 10 May 2016 10:23:27 +0000 http://knowledge.achieveee.com/?post_type=knowledge_base&p=2467 Laravel has an unified API for various queue back-ends. Queue allows us to process the time-consuming task faster, such as sending email which ultimately speed ups the web applications.

Steps to follow for creating Queue Listener:

  1. Install Supervisor

    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

     

  2. Create ‘/etc/supervisor/conf.d/laravel-worker.conf‘ and paste the below code into it

    [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

  3. Start the processes using following commands

    sudo supervisorctl reread
    sudo supervisorctl update
    sudo supervisorctl start laravel-worker:*

 

Now your queue listener is ready, let’s configure Laravel by following steps:


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);/* --}}
]]>
http://knowledge.achieveee.com/knowledge_base/create-queue-listener-in-laravel-5/feed/ 0
Clean and correct way to call a request internally in Laravel 5+ http://knowledge.achieveee.com/knowledge_base/clean-and-correct-way-to-call-a-request-internally-in-laravel-5/ http://knowledge.achieveee.com/knowledge_base/clean-and-correct-way-to-call-a-request-internally-in-laravel-5/#respond Fri, 06 May 2016 15:01:11 +0000 http://achieveee.com/knowledgebase/?post_type=knowledge_base&p=2456 To call a Laravel 5.* Request internally and complete the request life cycle, below are the steps to follow for various methods:

  1. GET

    $request = Request::create(url, 'GET');
    $response = Route::dispatch($request);
    return $response;
  2. POST (with parameters)

    $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

]]>
http://knowledge.achieveee.com/knowledge_base/clean-and-correct-way-to-call-a-request-internally-in-laravel-5/feed/ 0