Posts

PHP mkdir() Permission denied problem solved

Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user.
chown -R www-data:www-data /path/to/webserver/www

Next enabled all members of the www-data group to read and write files.
chmod -R g+rw /path/to/webserver/www

Delete a local and a remote GIT branch

Delete a local GIT branch
- git branch -d branch_name
- git branch -D branch_name

Delete a remote GIT branch
- git push <remote_name> --delete <branch_name>

How to Install Multiple PHP Version with Apache on Ubuntu 18.04 & 16.04

Apache InstallationInstall Apache web server from the official repository. Launch terminal on your system or login with ssh for remote systems. Execute the following commands to install the latest available version of Apache web server.

> sudo apt update 
> sudo apt install apache2 libapache2-mod-fastcgi 

//Ubuntu 18.04 Users:
> sudo apt install apache2 libapache2-mod-fcgid

PHP Installation For the installation of PHP versions, we use the PPA maintained here. Use the below couple of commands to add the PPA to your system.

> sudo apt install python-software-properties
> sudo add-apt-repository ppa:ondrej/php

For this tutorial, we are using the PHP 5.6 and PHP 7.2 to configure with Apache web server. To use the multiple PHP versions, we will use PHP FPM and FastCGI. Let’s install the following packages on your system.

> apt update
> sudo apt install php5.6 php5.6-fpm
> sudo apt install php7.2 php7.2-fpm
After installation, php-fpm services will be started automatically.

U…

doctrine/lexer Issue - Can't install because php 7.2 is required by doctrine/lexer

For some reason packages need to be added to composer.lock as some platform with specific PHP version,
you can define the platform field in composer.json file.

The composer.json which would add and install package versions to composer.lock as PHP 7.1.0 platform:

...
"require": {
    "php": "^7.1"
},
"config": {
    "platform": {
        "php": "7.1.0"
    }
},
...

Directory ownership change and mode change - Linux

- sudo chown hasib:hasib html/
- sudo chmod +x html/
- sudo chmod -R 777 html/

CURL

*** Initialize a cURL session
$ch = curl_init();

*** Set the URL that you want to GET by using the CURLOPT_URL option.
curl_setopt($ch, CURLOPT_URL, $url);

*** Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

*** Set CURLOPT_FOLLOWLOCATION to true to follow redirects.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

*** Timeout after 120 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120);

*** Start counting time for response from BL API.
$time_start     = microtime(true);
$requestTime    = Carbon::now()->format('Y-m-d H:i:s');

*** Execute the request.
$response   = curl_exec($ch);

*** End counting, and calculate time for response from BL API.
$time_end       = microtime(true);
$responseTime   = Carbon::now()->format('Y-m-d H:i:s');
$execution_time = ($time_end - $time_start)*1000;

*** Return a string containing the last error for the current session
$err  = curl_error($ch);

*** Close the …