Category Archives: php

Two Factor Authentication (2FA) with Google Authenticator & PHP – Tutorial

Note: This tutorial is an improvement over the article written by Rich Barrett on medium.com way back in Nov 2017 (see this link). However, there are some missing parts in that article that are necessary to complete the circle. This write-up tried to address those gaps. Introduction Google Authenticator is a token generator, that generates random and unique tokens for a validity of 30 seconds. Many web applications these days implement two-factor authentication in some form or the other. One of the popular methods is…

Read More »

Install Apache PHP and MySQL on macOS Sierra

Note:This is for fresh installations. Refer https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions for more details /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” brew tap homebrew/homebrew-php brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/php sudo apachectl stop sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null brew install httpd24 –with-privileged-ports –with-http2 brew install homebrew/apache/httpd24 –with-privileged-ports –with-http2 sudo cp -v /usr/local/Cellar/httpd24/2.4.25/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist brew install php71 –with-httpd24 sudo nano /usr/local/etc/apache2/2.4/httpd.conf <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> brew services start homebrew/php/php71 sudo apachectl -k restart nano…

Read More »

Enable FreeType and recompile PHP on Linux

FreeType library is typically required along with GD library in PHP. This will enable usage of imagettftext() and other functions. Install FreeType Install FreeType library first at OS level. # yum install freetype-devel You have to add the installed path to the PHP configure command.. FreeType will be installed in /usr/include/freetype2 on RHEL. find / -name freetype Enable FreeType in PHP You have to get the configure command first. Use php -i | grep “Configure” command and get the configure command. It will be something like this. ./configure  –prefix=/usr/local/php7 –with-mysqli=/usr/bin/mysql_config…

Read More »

Number to words in php

NumbWordter is a number to word converter class written in php. This class will be useful to display numbers as words. Usage: $converter=new NumbWordter(); echo $converter->convert(1823912); // echoes – One million, eight hundred and twenty three thousand, nine hundred and twelve Remember these..  The class uses “million” terminology to name the number. [Thousand, million, billion, trillion, quadrillion, quintillion, sextillion, septillion, octillion, nonillion, decillion, unidecillion, duodecillion, tredecillion and quattuordecillion] If no number is passed, there will be no output.  The length of number passed, should be maximum…

Read More »

error: Uh oh ...