Monday, September 24, 2018

fatal: refusing to merge unrelated histories

In my case, error was just fatal: refusing to merge unrelated histories on every especially first pull request after remotely adding a git repo.
Using --allow-unrelated-histories flag worked with pull request in this way:
git pull origin branchname --allow-unrelated-histories

Tuesday, September 18, 2018

How to remove "api" Prefix from URL

For Laravel 5.5:wn vote
accepted
It's just prefix to differ your api routes from other routes. You can add something different from apito here.
In app\Providers\RouterServiceProvider change this function:
   /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }
Remove prefixe line:
   /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

Monday, September 10, 2018

Laravel 5.4: Specified key was too long error

Laravel 5.4 made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.
For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php file and inside the boot method set a default string length:
use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

Friday, September 7, 2018

Target [Illuminate\Contracts\Routing\ResponseFactory] is not instantiable on calling Response::json using Response Facade in Lumen 5.4.3

Target [Illuminate\Contracts\Routing\ResponseFactory] is not instantiable on calling Response::json using Response Facade in Lumen 5.4.3


Here's the error

in Container.php line 804
at Container->notInstantiable('Illuminate\\Contracts\\Routing\\ResponseFactory') in Container.php line 687
at Container->build('Illuminate\\Contracts\\Routing\\ResponseFactory') in Container.php line 565
at Container->make('Illuminate\\Contracts\\Routing\\ResponseFactory') in Application.php line 208
at Application->make('Illuminate\\Contracts\\Routing\\ResponseFactory') in Container.php line 1070
at Container->offsetGet('Illuminate\\Contracts\\Routing\\ResponseFactory') in Facade.php line 159
at Facade::resolveFacadeInstance('Illuminate\\Contracts\\Routing\\ResponseFactory') in Facade.php line 128
at Facade::getFacadeRoot() in Facade.php line 215
at Facade::__callStatic('json', array(array(***))) in AppResponse.php line 31

Found a fix from tymondesigns/jwt-auth#532
In bootstrap/app.php uncomment this line $app->register(App\Providers\AppServiceProvider::class);
In the file App\Providers\AppServiceProvider update the register method to add:
/**
     * Register any application services.
     */
    public function register()
    {
        // ...
        $this->app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app) {
            return new \Illuminate\Routing\ResponseFactory(
                $app['Illuminate\Contracts\View\Factory'],
                $app['Illuminate\Routing\Redirector']
            );
        });
        // ...
    }

ReflectionException' with message 'Class path.storage does not exist

after run:
 php artisan migrate

got this errors:
PHP Fatal error:  Uncaught ReflectionException: Class path.storage does not exist in C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Container\Container.php:752
Stack trace:
#0 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Container\Container.php(752): ReflectionClass->__construct('path.storage')
#1 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('path.storage')
#2 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('path.storage', Array)
#3 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\lumen-framework\src\Application.php(230): Illuminate\Container\Container->make('path.storage', Array)
#4 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php(110): Laravel\Lumen\Application->make('path.storage', Array)

#5 C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Fo in C:\xampp\htdocs\lumen\iq-api\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 752


In my case (lumen 5.3.3) got fixed by adding following lines right after $app definition in bootstrap/app.php file:
$app = new Laravel\Lumen\Application(
        realpath(__DIR__ . '/../')
);

$app->instance('path.config', app()->basePath() . DIRECTORY_SEPARATOR . 'config');
$app->instance('path.storage', app()->basePath() . DIRECTORY_SEPARATOR . 'storage');

//$app->withFacades();
$app->withEloquent();
Summery is only add following two lines,
$app->instance('path.config', app()->basePath() . DIRECTORY_SEPARATOR . 'config');
$app->instance('path.storage', app()->basePath() . DIRECTORY_SEPARATOR . 'storage');


Thursday, August 30, 2018

How to export a mysql database using Command Prompt?

First check if your command line recognizes mysql command. If not go to command & type in:
set path=c:\wamp\bin\mysql\mysql5.1.36\bin
Then use this command to export your database:
mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
You will then be prompted for the database password.
This exports the database to the path you are currently in, while executing this command

CSS is not loading on Magento 2 site

Refused to apply style “because its MIME type ('text/html') is not a supported stylesheet MIME type”

Refused to apply style from 'https://xxxxxxxxxxxx.com/pub/static/version1502029409/adminhtml/Magento/backend/en_US/css/styles-old...' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."


The problem was solved when I re-deployed the assets for admin pages.
I run these commands:
  1. grunt clean; grunt exec; grunt less
  2. bin/magento setup:static-content:deploy -f -s standard
  3. bin/magento cache:clean
Maybe, the CSS has to be re-deployed whenever the Sales email templates are updated.