Skip to main content

Posts

Showing posts from August, 2017

Cakephp 3x Send Email with Cronjob

Cakephp 3.x - Send Email with Cronjob Easily Set Cron job with cakephp 3.x A Cron job is a task that is run based on time interval , we just need to set cron job from our cpanel and it will run automatically backend side . We can run cron job every minute , every hour, every day or every month based on our requirement. In cakephp 3.x to set a cron job please follow the below simple steps First we need to create a php file on webroot so we can run our controller action as php file in cronjob Create a file cron.php in webroot folder (location - YourProject/webroot/cron.php) and paste the following code Cron.php <?php $_SERVER[ 'HTTP_HOST' ] = 'yourdomain.com'; //  use only domain name here require dirname(__DIR__) . '/config/bootstrap.php'; use Cake\Network\Request; use Cake\Network\Response; use Cake\Routing\Router; use Cake\Routing\DispatcherFactory; if(PHP_SAPI == "cli" && $argc == 2) {     $dispatcher = DispatcherFacto

LARAVEL 5x CHECK STATUS ACTIVE BEFORE LOGIN

LARAVEL 5x CHECK STATUS ACTIVE BEFORE LOGIN For this tutorial we are using laravel 5.4 and we will add validation to user login that if user status is active then user can login otherwise if user status is not active then show error to user. so follow the below steps. The best way to add status validation is through a middleware to check status . so we are creating middleware and we will use it in loginController. Run the following command in console or cmd to create checkStatus middleware .   php artisan make:middleware CheckStatus after completion of command " Middleware created successfully " will show. then paste the below code into file . <?php namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; class CheckStatus {     /**      * Handle an incoming request.      *      * @param  \Illuminate\Http\Request  $request      * @param  \Closure  $next      * @return mixed      */     public function handle($request,