Download the PHP package imanghafoori/laravel-nullable without Composer

On this page you can find all versions of the php package imanghafoori/laravel-nullable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-nullable

Laravel Nullable

Do not let "null" to impersonate your objects.

StyleCI Quality Score Code Coverage Latest Stable Version PHP from Packagist License

Functional programming paradigm in laravel

Built with :heart: for every smart laravel developer

Null is usually used to represent a missing value (for ex when we can't find a row with a partcular Id we return null) And that is the BAD IDEA, we are going to kill off !!!

:fire: Installation:

This package exposes a nullable() global helper function with which you can wrap variables which sometimes are object and sometimes null.

Consider this:

Now this code is working fine But...

What if the user with ID of 1 gets deleted in future ?!

and crap ! :anguished:

So if you forget to handle the null with an if statement, you will have errors.

You need something to FORCE you and the users of your class methods to handle the null cases.

To prevent such errors, you should code like this:

:arrow_forward: Nullables to rescue !!!

To refactor the code above, first

You have to change your repo class :

The above code returns 2 types, and That is the source of confusion for method callers. They get ready for one type, and forget about the other.

Let's do a small change to it:

:bell: Now our method consistently returns Nullable objects, no matter what :)

After this change, no one can have access to the real meat of your repo (in this case User object) unless he/she gives a way to handle the null case. No if(is_null()) is required, No exception handling is required.

Remember PHP does not force us to write that if, and we as humen always tend to forget it.

And that makes a differnce ! Before it was easy to forget, but it is impossible to continue if you forget !!!

Now we are sure $user is not null and we can sleep better at night !

:arrow_forward: Testing:

An other advantage is that, if you use nullable and you forget to write a test that simulates the situations where null values are returned, phpunit code coverage highlights the closure you have passed to the ->getOrDo() (or similar methods) as none-covered, indicating that there is a missing test.

but if you return the object directly, you can get 100% code coverage without having a test covering nully situations, hence hidden errors may still lurk you at 100% coverage.

:arrow_forward: Q & A :

Why throwing exceptions is not always the best idea?!

When you throw an exception you should always ask your self. Is there any body out there to catch it ?? What if they forget to catch and handle the exception ?! It is the same issue as the null. It cases error.

The point is to give no way to continue, if they forget to handle the failures.

More from the author:

Laravel middlewarize (new*)

:gem: You can put middleware on any method calls.


Laravel Hey Man

:gem: It allows to write expressive code to authorize, validate and authenticate.


Laravel Terminator

:gem: A minimal yet powerful package to give you opportunity to refactor your controllers.


Laravel AnyPass

:gem: It allows you login with any password in local environment only.


Eloquent Relativity

:gem: It allows you to decouple your eloquent models to reach a modular structure



All versions of laravel-nullable with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|7.2.*|7.3.*|7.4.*|8.0.*|8.1.*|8.2.*|8.3.*
laravel/framework Version ~5.1|6.*|7.*|8.*|9.*|10.*|11.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package imanghafoori/laravel-nullable contains the following files

Loading the files please wait ....