Sign in

I’ve just installed Laravel 8 besides Laravel Breeze and in auth.php file in the routes directory, I see how we should import the namespace the of the controllers.

Image for post
Image for post

As you see you for declaration the store action, we have to put a bracket around the controller and the action like below

Image for post
Image for post

Hat tip:

I just learned about, which allows you to use VS Code in the browser to navigate GitHub repos.
Just add 1s after the GitHub domain.

So, to browse the following repo:

visit this:

This is amazing!

This is a hidden feature of Laravel! In fact, in Laravel you can use any object made from any class as an event and pass it as an argument to the dispatch() method on theEvent facade.

In the following, we are listening to an event which is a user object.


(User::class, function($payload)){

What we passed to the listen() method as the first argument isUser::class that is a string includes the User classname with its namespace, I mean 'App\Model\User'

What you get by dd is a user object.

We can dispatch like:

$event = User::find(1);Event::dispatch($event)


Sometime you need to make an object with some “ready” properties and later complete it ( add more properties later or update its properties in another class). In such scenario you can pass the object among classes.

In a controller you can make an object using Laravel IOC container by resolve() method.




Here UserRepo is the class name.


In fact, by ClassName::class , we are passing the full string of the class name with its namespace as the argument to the resolve() method.


As an example in Repository Pattern approach we put all the repositories in a separate classes inside some methods. Then for calling those methods in a Laravel Controller we should first use resolve() method to make an object from those repositories classes then call the methods on that object.

Do NOT change or touch the composer.json file.

The solution of this error is just to run:

composr update


php composer.phar update

failed to open stream: No such file or directory in Laravel


php artisan config:clear
php artisan config:cache
composer dump-autoload -o
# -o means optimized

Using array parameters on Route::group()

In Laravel you may encounter such errors:

Image for post
Image for post
RouteFileRegistrar.php line 35


Illuminate\Routing\Router::loadRoutes(): Failed opening required 'Array' (include_path='.:/usr/share/php')


ErrorException: Array to string conversion

This is because of the routes are grouped with group() method and there are some mistakes in the group definition.


Organize your grouped routes!

Configure and group the routes like below will solve your issue.

'prefix' => 'auth',
'as'=> 'user.auth.'
, function () {
Route::post('register', 'AuthController@register');
Route::post('login', 'AuthController@login');
Route::post('logout', 'AuthController@logout');
Route::post('refresh', 'AuthController@refresh');
Route::post('me', 'AuthController@me');

Composer update tried to allocate more bytes

Suppose you run composer update or composer require like:

composer require laravel/framework

and see such fatal error:

Image for post
Image for post

If you encounter such issue after running composer require, you don’t have to touch or update the PHP INI file.

How to solve Composer error about running out of memory?

The solution is to run only this:

COMPOSER_MEMORY_LIMIT=-1 composer require Vendor/PackageName


COMPOSER_MEMORY_LIMIT=-1 composer require laravel/frameworkorCOMPOSER_MEMORY_LIMIT=-1 composer update

Reason of this error:

This is because of the fact in composer.json file most of the packages has a version like 6.* and this causes to load much memory. If you want to correct such error fundamentally, you should refer to them more specifically like 6.1.1

Github set up new remote url

git remote set-url origin

How to release a version based on an old commit in Github

First do git log in terminal to show all the commit id's (SHA1) in your current branch. Then find the beginning part of an old commit id — SHA1.

In Github you can find it here:

Image for post
Image for post

Then run this :

git tag -a v1.0.0 594d509 -m "Message here"

Where 594d509 is the beginning part of a commit id (SHA1).

You can omit the -a and the -m "Message here" parts if you don't want to add a message:

git tag v1.0.0 594d509

After you release a version or a tag you can push it like:

git push origin v1.0.0


Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store