Laravel Lumen API Validate Json Array

February 18, 2021

I have this json array as my request data from API. Example input: { “name”: “Test Bundle”, “sku”: “SKU123″, “qty_available”: “2″, “items”:[ { "sku": "SKU123-1", "qty_required": "1", "item_price": "32.00" }, { "sku": "SKU123-2", "qty_required": "1", "item_price": "12.00" } ] } Validation in laravel: // validate request data $bundle_data = $this->validate($request, [ 'name' => 'required|string|min:1|max:255', 'sku' […]

Magento 2 Error Can’t run this operation: deployment configuration is absent.

January 5, 2021

We all know that Magento has CLI command. You can call Magento CLI commands using shortcuts instead of the full command name. For example, you can call bin/magento setup:upgrade using bin/magento If you sees this error:  Can’t run this operation: deployment configuration is absent. Run ‘magento setup:config:set –help’ for options. Please check whether your two files are […]

MAC Big Sur NGINX Installation PHP-FPM error

December 28, 2020

After PHP7 installation and try run $ php-fpm Below error: ERROR:failed to open configuration file ‘/private/etc/php-fpm.conf’: No such file or directory.. It is due to the configuration file with the path /private/etc/php-fpm.conf and the file does not exist. To solve this cp /private/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf After copying this file, you need to modify some of the things in […]

Laravel 7 Digitalocean managed database error: The server requested authentication method unknown to the client

July 20, 2020

I am using Laravel 7 to do testing on DigitalOcean’s managed database cluster. Laravel connection doesn’t work, with error and I have fo find the fix that causing it. Illuminate\Database\QueryException SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client This issue has been fixed in PHP7.4, please install PHP7.4 in the Droplet. If […]

Laravel & NPM installation Steps

July 15, 2020

Create a new laravel project. $ composer create-project –prefer-dist laravel/laravel   my-project (NOTE: if you do not have composer, please install in your machine and make it global. This will make a lot easier) Or Clone the repository from github or your private repo. $ git clone <your repo> Install NPM globally if you haven’t installed that […]

PHP Apache2 Laravel Resource interpreted as Stylesheet but transferred with MIME type text/html: “

July 13, 2020

Depending on your server configuration. Some condition, it can be solved by creating an .htaccess file into your root folder (or update the existing one) with this line inside AddType text/css .css this will tell apache to send the right content-type header for .css file On my case, the above won’t work at all. My own hosted Ubuntu needs below changes so […]

[Phpmyadmin] Temporary disable phpmyadmin how to?

December 19, 2016

Phpmyadmin is an easy tools to have visualize interface to access database. If it is not in use, better to disable it to protect your site from hack or SQLInjection, You do not want to remove it, because in future it might be needed again, so just disable it in a simple way and enable […]

PHP get first day of current month, datepicker friendly

December 22, 2014

The simplest and readable way to do it is using this clean solution. All you need is a string represent the date. First day of the month: Last day of the month:

PHP script execution time tracking wallclock time

December 1, 2014

A simple way to find out execution time of php script without lots of calculation is tracks the wallclock time. Compare to tracking CPU time, it also include time that PHP is sat waiting for external resources such as disks or databases, which is not used for max_execution_time. Output: Execution time get user: 0.00023317337036133

PHP fgetcsv count lines end of file, eof

November 17, 2014

Due to fgetcsv read only a line from open file, or line by line if looping. As decribe below, it doesn’t able to return number of line from specific file. The fgetcsv() function parses a line from an open file, checking for CSV fields. The fgetcsv() function stops returning on a new line, at the […]