Category Archives: Programming

Convert GMT to Local timezone in PHP

Following code snippet converts a date time in GMT to Local timezone.

 

Requires Doctrine DBAL Laravel migration

If you are running a migration to change the data type of a column in a table. You might come across this error message in terminal.

This error message is telling you to install doctrine/dbal to make this work. You can learn more about this package here https://github.com/doctrine/dbal

To install this package through composer, run following command in terminal.

Now you can run your migration by running

This should work now.

npm install – Please try running this command again as root/Administrator

If you are getting this error while running npm install, then you are not having write permission on .npm directory.

To get the ownership of this directory run following command

Also we need to give write permission to node_modules directory

ref – http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo

Install Mcrypt PHP extension on Ubuntu (PHP-FPM + Nginx)

To install Mcrypt PHP extension on Ubuntu / Debian run following command ( this step is same for Nginx and apache )

This will create a mcrypt module in /etc/php5/mods-available directory. If it doesnt we need to create symlink for this.

Now enable mcrypt by running

After this restart php5-fpm service by

 

How to access remote mysql server using local phpmyadmin

phpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL or MariaDBwith the use of a web browser. It can perform various tasks such as creating, modifying or deleting databases, tables,fields or rows; executing SQL statements; or managing users and permissions. source: wikipedia

To access remote mysql database from your local phpmyadmin, open config.inc.php file by

Add following line

You can refer this article to install phpmyadmin on Ubuntu: http://devendraverma.com/install-phpmyadmin-on-ubuntu/

Android Splash Screen

To add Splash Screen to you android application


Splashscreen.java

AndroidManifest.xml

 

activity_splash.xml

Output

laterbox_splash_screen

 

 

Remove # from url in Angular JS and Laravel 5

To remove # from Angular JS application built with Laravel , add following line in your config.

Add this in your head tag

Now it will work fine till you do not refresh the page. If you refresh your page at this point, you will see page not found error, it is because now browser sends request to server and server doesn’t have the route.

To do this we will add this route at the end of routes.php

 

 

PHP Fatal error: Uncaught exception ‘UnexpectedValueExcepti$

After fresh installation of Laravel 5.1, it was not showing up the welcome page. Further investigating into this issue revealed that “storage” directory is not writable.

To make storage directory writable run following commands

Then run: