PHP: Debug Backtrace with Example

This article shows how we can use the debug_backtrace() PHP function to generate a backtrace. This function returns an array of associative arrays. It includes the current function name, file name, class name, line number, etc. where the debug backtrace function was called. Syntax debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array Parameters $options … Read more

Set up PHP Development Environment with Docker

This article shows how you can set up a PHP development environment using Docker. We will be installing PHP, MySQL & Nginx, and PHPMyAdmin in the docker containers. Here’s a basic introduction to docker and docker tools & terminologies: Introduction to Docker and its Tools & Terminologies. Pre-requisites Docker should be installed on your machine: … Read more

Enable Xdebug in VSCode for PHP

Xdebug is a PHP extension that provides debugging and profiling capabilities. This article shows how you can enable and use Xdebug in the VSCode code editor. Install Xdebug Xdebug installation instruction is present here: https://xdebug.org/docs/install You can also follow these steps to get detailed instructions on installing Xdebug based on your system (Mac, Linux, Windows): … Read more

Composer Update: Allowed memory size exhausted

When I run composer update, I got memory limit error: Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 167772160 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 90 Tried solution from here: https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors Same error when I try: $ COMPOSER_MEMORY_LIMIT=-1 composer update Checked PHP memory limit: $ php -i | grep memory_limit memory_limit => … Read more

PHP: Scrap Web Page Content using Simple HTML DOM Parser

This article shows how you can scrap or fetch any webpage’s HTML content/data in PHP. We will use Simple HTML DOM Parser to scrap webpage content. You can download it from here: PHP Simple HTML DOM Parser – Sourceforge You need to download the HTML DOM Parser from sourceforge and include simple_html_dom_parser.php in your PHP … Read more

MailChimp API v3.0 – Add Store to List, Add Product to Store, Add Order to Campaign

This article shows how you can use MailChimp API v3.0 with PHP and CURL to add ecommerce data to your MailChimp campaign. When purchases happen in your shop then you can add your purchase order data to MailChimp to track purchases from your MailChimp Campaign. A MailChimp campaign is associated to any particular MailChimp list. … Read more

PHP: Get Timezone & Time Difference from Latitude & Longitude using Google Maps Time Zone API

This article shows how you can get TimeZone name and id in PHP from latitude and longitude value by using Google Maps Time Zone API. Note that: You need to put your API Key in the maps api url like this: https://maps.googleapis.com/maps/api/timezone/json?location=$latitude,$longitude&timestamp=$time&key=xxxxxxxxxxxxxxxxxxxxx You can get the API key from here: Get API Key Here is … Read more

PHP: Get Latitude/Longitude using Google Maps API

Here is a quick PHP code to fetch latitude and longitude of any given place using Google Maps API. CURL is used to fetch data from the API URL. $address = "Kathmandu, Nepal"; $url = "http://maps.google.com/maps/api/geocode/json?address=".urlencode($address); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $responseJson = curl_exec($ch); curl_close($ch); $response = json_decode($responseJson); if ($response->status == … Read more

PHP & MongoDB: Very Simple Add, Edit, Delete, View (CRUD) [Beginner Tutorial]

In this article, I will be presenting simple PHP & MongoDB code to add, edit, delete and view data. This kind of system is also referred to CRUD (Create, Read, Update, Delete). Here is a step-by-step guide on creating a CRUD system using PHP & MongoDB: I suppose, you have already installed MongoDB. If not, … Read more