Skip to content

mabjavaid/user-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UserLib

Installation

To set up the package please run following command in your project.

composer require mabjavaid/user-lib

Supported laravel Versions

  • Laravel 8.x
  • Laravel 9.x

Usage

  • To get a single user by id you can call following method.
    • Namespace => Mabjavaid\UserLib\UserLib
    • UserLib::getUserById($id)
  • To get all users you can call following method.
    • Namespace => Mabjavaid\UserLib\UserLib
    • UserLib::getAllUsers($pageNumber)
  • To create a new user you can call following method.
    • Namespace => Mabjavaid\UserLib\UserLib
    • UserLib::createUser($name, $job)

Challenges and Solutions

  • C1: Remote APIs are often unstable and unreliable; how will you handle this?
    • I am using custom exception ReqresException to communicate errors to other developers utilising this package with clear message and error code.
    • I develop a custom exception to handle api related exceptions
    • I am catching api related exceptions and throwing custom exception with clear message and error code.
    • FYI: for other validations e:g parameters i will do the following
      • I will use laravel validation (Request Class => set payload using request() helper) to validate the parameters and throw custom validation exception with clear message and error code.
  • C2: How can you make your code testable?
    • Unit tests are written and covering every expect of written code.
    • We should never make live request to a third party when testing.A good developer will always mock the test data and response
  • Package is developed using php 8.0 and laravel 9.x. It is tested on laravel 9.x and php 8.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages