Nasrul Hazim Bin Mohamad

Laravel: Observer Setup Enhancement

Apr
24

Assalamualaikum,

It’s been awhile since my last blog post. Today, just want to share something simple, an enhancement of LARAVEL: CREATE HASHED ID FOR A RESOURCE USING OBSERVER. Going to refactor a bit.

First, let’s modify the app/Observers/Kernel.php, to be like the following:

Next, add new config file for our observer – config/observers.php:

And that’s it!

Very simple and straightforward setup of Laravel Observer, much cleaner than before.

Should I make this as a package? Do let me know if you guys need this as a package. šŸ™‚

Thanks

Laravel: Package Generator

Dec
31

Assalamualaikum / Hi,

It’s been a long time, I wan to update my Laravel Package Generator and now it’s officially updated with version 2.0.2.

Lots of experience, study case, observation, setting up things in Laravel package. Now I believe, it’s ready to speed up your Laravel Package Development.

So, what the Packager do? Basically it creates a basic skeleton of Laravel package which consist of:

  1. Service Provider
  2. Facade
  3. README – with Installation instruction, License Term ready! Other details you need to update manually.
  4. Dependencies – phpunit/phpunit, orchestra/testbench and codedungeon/phpunit-result-printer
  5. LICENSE
  6. phpunit.xml
  7. helpers

See my tweet on this package

That’s all, thanks!

4 Essential Laravel Packages for Your Web Application Development

Dec
20

Assalamualaikum,

Recently I’ve been working with developing Laravel packages for my own use and Laravel’s community. It’s quite fun and interesting how you can separate the modules or features from Laravel’s main application and make it as a package, which later on you can reuse it over and over again.

Here are some of the packages I’ve created so far. You may want to try it out, and please do make a report if there’s any issues.

  1. Artisan Extended – this package mainly to add more artisan commands to simplify and speed up your development progress.Ā Here the list of commands available:
    1. clear:cache – Put application under maintenance, clear common caches files, and put the application up again
    2. clear:serve – Run clear:cache and serve the application
    3. make:route – Create a new route
    4. make:view – Create a new plain view or resourceful view
    5. make:resourceful – Create a new resourceful controller
    6. make:scaffold – Create a new model, migration, resourceful controller and views (but still, need to enhance to accept columns details)
    7. secure:cookie – Secure your cookie
  2. Themer – The package main purpose to support theming in Laravel’s applications. It’s provide a middleware, and an artisan command(make:theme) to create a new theme.
  3. Setting – A simple helper to have a setting for your application.
  4. Subscriptions – TheĀ package is used for SaaS based applications. It’s allow you to add new packageĀ services, and enable your customers to subscribe to your SaaS application.
Sample Subscription Implementation in SaaS Application

Sample Subscription Implementation in SaaS Application

Do play around with the packages, and do report issues if there’s any, or if you think there’s need enhancement, do submit your proposal.