Ubuntu20.04 Install Apache PHP MySQL on Digital Ocean Droplet

First create a Digital Ocean Droplet with OS Ubuntu20.04, choose password login for SSH into droplet. # apt update # apt install unzip -y # apt install curl -y Install Apache & MySQL Server # apt install apache2 -y # apt install mysql-server -y # mysql_secure_installation (it will ask you MySQL server login new password) … Read more

Fatal error: Allowed memory size of 8388608 bytes exhausted

PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y) in file.php 1. memory_limit globally from php.ini memory_limit = 64M 2. memory_limit using .htaccess php_value memory_limit 64M 3. memory_limit inside a php script. ini_set(‘memory_limit’, ’64M’); To change the memory limit for one specific script by including a line such as this … Read more

Recursive Function for Nested Categories

Nested Categories over Drop Down Categories and its sub categories are always useful while developing simple to huge applications. Here is a simple php code to create multi-leveled nested categories on select box to those categories. CREATE TABLE `tb_category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pid` int(11) NOT NULL, `name` varchar(255) NOT NULL PRIMARY KEY … Read more

json_add for php

JSON (JavaScript Object Notation) is a lightweight data-interchange format. 1. Easy for humans to read and write. 2. Easy for machines to parse and generate. 3. Collection of name/value pairs. 4. Used for C, C++, C#, Java, JavaScript, Perl, Python, and many others. 5. Compatible with universal data structures – array, vector, list, or sequence. … Read more

Override PHP Function

PHP have PECL (PHP Extension & Community Library) function to override built-in functions by replacing them in the symbol table. bool override_function ( string $function_name , string $function_args , string $function_code )   <?php override_function(‘strlen’, ‘$string’, ‘return override_strlen($string);’); function override_strlen($string){ return strlen($string); } ?> The above function “override_function()” require APD i.e. Advanced PHP Debugger. We … Read more

PHP ORM – Create select box with mysql set or enum

PHP have rich set of functions to solve real time problems in programming and web development.. thanks to Rasmus Lerdorf eval — Evaluate a string as PHP code A SET datatype can hold any number of strings from a predefined list of strings. The ENUM datatype restricts to a single member of the set of … Read more

CakePHP vs YII

Have you checked my previous article on CakePHP… https://www.svnlabs.com/blogs/cakephp-in-svnlabs/ Yii (Yes, it is) — a high-performance component-based PHP framework best for developing large-scale Web applications. Yii have features, including MVC, DAO/ActiveRecord, I18N/L10N, caching, jQuery-based AJAX support, authentication and role-based access control, scaffolding, input validation, widgets, events, theming, Web services, and so on. Written in strict … Read more

Framework vs CMS

Framework: A web application framework is a software framework that is designed to support the development of dynamic websites, Web applications and Web services. 1. CodeIgniter 2. CakePHP 3. Zend 4. Symfony CMS: A content management system (CMS) is the collection of procedures used to manage work flow in a collaborative environment. These procedures can … Read more

Create ZIP archives with PHP script and PEAR class

We can use PEAR to process zip files in PHP using Archive_Zip…. First set PEAR path in php include path using set_include_path Make Zipped file <?php include (‘Archive/Zip.php’);        // include PEAR ZIP package $obj = new Archive_Zip(‘test.zip’);  // zipped file name $files = array(‘svnlabs/1.gif’, ‘svnlabs/resume.doc’, ‘svnlabs/invoice.xls’);   // files add to zip if ($obj->create($files)) { echo … Read more

PHP – File Upload Stream

PHP supports upload file stream… we can stream data to server using PHP stream_open() & stream_write() functions. There is alternate method in PEAR to transfer files to server1 to server2. PEAR have HTTP package for uploading files. HTTP_Request supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc. <?php require_once “HTTP/Request.php”; $req =& new HTTP_Request(“http://domain.com/upload”); $req->setBasicAuth(“login”, “pass”); $req->setMethod(HTTP_REQUEST_METHOD_POST); $result = $req->addFile(“data”, “/home/svnlabs.mp4”); … Read more