Laravel Lumen API Validation in Service Class

February 18, 2021

If you need a validation outside of controller such as service container or service class, below example code may help. Copy traits ProvidesConvenienceMethods from laravel/lumen-framework/src/Routing to your folder as convenient. Eg, App\Services folder. namespace App\Services\product; use App\Models\Products\Product; use App\Services\ProvidesConvenienceMethods; class ProductCreateService { use ProvidesConvenienceMethods; public function store($request) { // validate request data $product_data = $this->validator($request->all(), [ 'name' […]

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 […]

MySQL Your password does not satisfy the current policy requirements

December 28, 2020

This happened due to MySQL Validate Password Policy level is higher. You can see password validate configuration metrics using the following query in MySQL client: SHOW VARIABLES LIKE ‘validate_password%’; The output should be something like that : +————————————–+——-+ | Variable_name | Value | +————————————–+——-+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 6 […]

Mac OSX Kubernetes Run `brew link` on these: kubernetes-cli

July 26, 2020

You may see this error after installed Kubernetes and run “brew doctor”. Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: kubernetes-cli It can be solved by running below […]

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 […]

Mac OSX Composer Could not open input file: /Users//composer.phar

July 1, 2020

To most of the people who want to install composer on OSX, usually, the below command is sufficient: $ curl -sS https://getcomposer.org/installer | php $ mv composer.phar /usr/local/bin/composer $ alias composer=’/usr/local/bin/composer.phar’ However, it could still happen to have error of “Could not open input file: /Users/kayliongmac11air/composer.phar“ This is due to shell environment didn’t refresh. To fix this […]