I just learned about github1s.com
, 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:
https://github.com/HPWebdeveloper/Git-One-Command
visit this:
https://github1s.com/HPWebdeveloper/Git-One-Command
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.
Listen:
Event::listen(User::class, function($payload)){ dd($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.
resolve(ClassName::class)
Example:
resolve(UserRepo::class)
Here UserRepo
is the class name.
note:
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.
Usage:
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
or
php composer.phar update
php artisan config:clear
php artisan config:cache
composer dump-autoload -o # -o means optimized
In Laravel you may encounter such errors:
or
Illuminate\Routing\Router::loadRoutes(): Failed opening required 'Array' (include_path='.:/usr/share/php')
or
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.
Route::group(
[
'namespace'=>'Auth',
'middleware'=>'api',
'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');
});
Suppose you run composer update or composer require like:
composer require laravel/framework
and see such fatal error:
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
Example:
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
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
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:
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