Thursday, August 17, 2017

WordPress - init hook seems to be fired more than once

init hook should be fired only once in WP

If it appears as being fired more than once, it's probably because there was a redirect and/or 404 error (even for a PNG, it's going to trigger the full WP Load).

Also, there might be multiprocess/multithread execution. Every page load can run multiple wp processes in case of 404 errors or redirects! And they can enter a race condition!

Saturday, August 12, 2017

mysql 5.7 - disabling STRICT mode

If your app was written for older versions of MySQL and is not compatible with strict SQL mode in MySQL 5.7, you can disable strict SQL mode. For example, apps such as WHMCS 6 and Craft 2 do not support strict SQL mode.

If you're using WHMCS 7, see our article on customizing MySQL for WHMCS 7.
To disable strict SQL mode, SSH in to your server as root and create this file:

Open the file and enter these two lines:

Restart MySQL with this command:

sudo service mysql restart
This change disables two SQL mode settings, STRICT_TRANS_TABLES and ONLY_FULL_GROUP_BY, that were added in MySQL 5.7 and cause problems for some older applications.

Full details here

Friday, August 4, 2017

npm, Homestead, and Windows - EIO npm error - solved

If you are using npm inside of a Homestead box which is being hosted in Windows, and you see a "Exit status 1" error , or EIO error thrown by npm scripts, make sure that you have downloaded the npm packages inside of Homestead box, and not in Windows.

Apparently, there could be some differences in encoding / character set which can result in npm errors inside of Homestead box.

So, inside your Homestead box, remove the node_modules file and re-run npm install. Now you should be able to run npm scripts normally.

Tuesday, August 1, 2017

Laravel Cashier - There are no commands defined in the "cashier" namespace. [Solved]

In Laravel 5.4, when trying to use Laravel\Cashier, the following error can sometimes occur:
There are no commands defined in the "cashier" namespace.

The solution is to manually create the migration file and execute it:

Run this:
php artisan make:migration add_cashier_table_fields
And then, in the created empty file, add this:



use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddCashierTableFields extends Migration
     * Run the migrations.
     * @return void
    public function up()

         Schema::table('users', function ($table) {
        Schema::create('subscriptions', function ($table) {

     * Reverse the migrations.
     * @return void
    public function down()


Now, you can execute the command:
php artisan migrate

Original solution is here:

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...