I'm enthusiastic and passionate about web development and design in all it's forms and love to build application with efficient and simple methods

Tuesday, November 18, 2014

Build Background Job in Laravel Using Cron Job

7:09 AM Posted by Codeinterpreter , 1 comment
Cron Job with Laravel running with Artisan Command. So we have to make command using Artisan.

Generate Class.
php artisan command:make FooCommand 
php artisan command:make [[your command]]
This command will generate a class in app/commands.

Write Your Function
Write your functions in your generated command fire() method.

Register Command
Write: Artisan::add(new [[your command]]);
In app/start/artisan.php

Runs Cron Job
Write in terminal : crontab -e
Write:
* * * * * php [[path to application]]/[[your application]]/artisan background:process
* * * * * : it means this cron job will be executed every minutes

MongoDB in PHP

6:40 AM Posted by Codeinterpreter , , No comments
The MongoDB PHP driver should work on nearly any system: Windows, Mac OS X, Unix, and Linux; little- and big-endian machines; 32- and 64-bit machines; PHP 5.2, 5.3, 5.4 and 5.5.

Install MongoDB Driver PHP

  • sudo pecl install mongo
  • Add extension=mongo.so in php.ini (/etc/php5/cli/php.ini)
  • Restart Apache: sudo service apache2 restart
Check Installed MongoDB
  • Check is MongoDB extensions already loaded in your PHP php --ini
    already installed: /etc/php5/cli/conf.d/mongo.ini
  • Check is MongoDB extesions already enabled php -i | grep 'Mongo' Already Enabled: MongoDB Support => enabled
  • Type <? phpinfo(); in your PHP applications.

Install MongoDB on Ubuntu

6:25 AM Posted by Codeinterpreter , No comments
MonggoDB provides package that supported officially. This package contains:

  • mongodb-org
  • mongodb-org-server
  • mongodb-org-mongos
  • mongodb-org-shell
  • mongodb-org-tools
Install MonggoDB Package.

  • Import Public Key used by Management System.
    Type on Terminal: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  • Create List File.
    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
  • Update Package.
    sudo apt-get update
  • Install MongoDB package
    sudo apt-get install -y mongodb-org


Running MongoDB
  • sudo service mongod start
MongoDB Shell
  • type: mongo