{"id":46732069,"url":"https://github.com/spotlibs/php-lib","last_synced_at":"2026-03-09T15:31:39.511Z","repository":{"id":252466011,"uuid":"832104378","full_name":"spotlibs/php-lib","owner":"spotlibs","description":"Standardized reuseable pkg for PHP","archived":false,"fork":false,"pushed_at":"2026-02-26T03:06:30.000Z","size":904,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-26T07:56:55.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spotlibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-22T11:10:21.000Z","updated_at":"2026-02-20T03:32:18.000Z","dependencies_parsed_at":"2024-12-30T11:20:00.045Z","dependency_job_id":"c102d150-5578-4f13-bcc7-ed79e4d0aeda","html_url":"https://github.com/spotlibs/php-lib","commit_stats":null,"previous_names":["brispot/php-lib","spotlibs/php-lib"],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/spotlibs/php-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotlibs%2Fphp-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotlibs%2Fphp-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotlibs%2Fphp-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotlibs%2Fphp-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spotlibs","download_url":"https://codeload.github.com/spotlibs/php-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotlibs%2Fphp-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30301109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-09T15:31:37.155Z","updated_at":"2026-03-09T15:31:39.481Z","avatar_url":"https://github.com/spotlibs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spotlibs-php-lib\n\n[![Build Status](https://github.com/spotlibs/php-lib/actions/workflows/php.yml/badge.svg)](https://github.com/spotlibs/php-lib/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/spotlibs/php-lib)](https://packagist.org/packages/spotlibs/php-lib)\n[![Latest Stable Version](https://img.shields.io/packagist/v/spotlibs/php-lib)](https://packagist.org/packages/spotlibs/php-lib)\n[![License](https://img.shields.io/packagist/l/spotlibs/php-lib)](https://packagist.org/packages/spotlibs/php-lib)\n\n## Description\nThis library is used to support easier development of Spotlibs Microservice Project.\n\nThis library provides rest client for communication between microservice.\nThis library provides kafka client both producer and consumer with support avro serde.\n\n## Install\n\n    composer require spotlibs/php-lib\n\n## Usage\n- Exception\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Spotlibs\\PhpLib\\Exceptions\\StdException;\nuse Spotlibs\\PhpLib\\Exceptions\\AccessException;\n\nclass ExceptionUsage\n{\n    public function ThrowingException()\n    {\n        throw new AccessException('You shall not pass!');\n    }\n\n    // you can also throw any exception by static function of StdException\n    public function ThrowingStandardException()\n    {\n        throw StdException::create(\n            StdException::HEADER_EXCEPTION,\n            'Invalid headers to access this resource',\n        );\n    }\n}\n```\n- Response\n\nStandardized response body for a consistent response body structure\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Spotlibs\\PhpLib\\Responses\\StdResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Response;\nuse App\\Http\\Controllers\\Controller;\nuse App\\Models\\Post;\n\nclass DailyNews extends Controller\n{\n    public function index(Request $request): Response\n    {\n        Post::create([\n            'headline' =\u003e 'Top 10 Countries with Best Cyber Security, Finland Ranked First',\n            'content' =\u003e 'Here are the top 10 countries with the best cyber securities based on the data published by Mix Mode and 2024 Global Security Index:'\n        ]);\n        return StdResponse::success('Daily news posted.');\n    }\n}\n```\n- DTO\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Spotlibs\\PhpLib\\Dtos\\TraitDtos;\n\nclass Person\n{\n    use TraitDtos;\n\n    public string $name;\n    public int $age;\n    public array $hobbies;\n}\n\nclass Introduction\n{\n    protected Person $person;\n\n    public function __construct()\n    {\n        // pass associative array to construct DTO\n        $this-\u003eperson = new Person([\n            'name' =\u003e 'John',\n            'age' =\u003e 30,\n            'hobbies' =\u003e ['fishing', 'sleeping', 'coding']\n        ]);\n    }\n\n    public function index(): void\n    {\n        echo \"Hi, my name is \" . $this-\u003eperson-\u003ename . \". I am \" . $this-\u003eperson-\u003eage . \" year(s) old\" . PHP_EOL;\n    }\n}\n```\n- Context\n\nImplement a context as an object containing several key:value from the begining to the end of request lifecycle. To use context, add this service provider to your bootstrap/app.php for Lumen or config/app.php for Laravel\n```php\n$app-\u003eregister(\\Spotlibs\\PhpLib\\Providers\\ContextServiceProvider::class);\n```\n- Activity Middleware\n\nRequest and response middleware to initiate context and writing activity log. To use this middleware, add this line to your app middleware setting\n```php\n$app-\u003emiddleware([\n    //...\n    \\Spotlibs\\PhpLib\\Middlewares\\ActivityMonitor::class,\n    //...\n]);\n```\n- Logger\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Spotlibs\\PhpLib\\Logs\\Log;\n\nclass HoldingBeer\n{\n    public function HoldMyBeer()\n    {\n        Log::activity()-\u003einfo(['timestamp' =\u003e '2006-01-02 15:04:05', 'status' =\u003e 'accomplished']);\n        Log::worker()-\u003einfo(['timestamp' =\u003e '2006-01-02 15:04:05', 'job' =\u003e 'holding bro\\'s beer']);\n        Log::runtime()-\u003einfo(['timestamp' =\u003e '2006-01-02 15:04:05', 'error' =\u003e 'the beer likely to spilled']);\n        Log::runtime()-\u003ewarning(['timestamp' =\u003e '2006-01-02 15:04:05', 'error' =\u003e 'the beer gonna be spilled']);\n        Log::runtime()-\u003eerror(['timestamp' =\u003e '2006-01-02 15:04:05', 'error' =\u003e 'the beer got spilled']);\n    }\n}\n```\n- Queue\n\nadd this service provider to your bootstrap/app.php for Lumen or config/app.php for Laravel\n```php\n$app-\u003eregister(\\Spotlibs\\PhpLib\\Providers\\QueueEventServiceProvider::class);\n```\n\nand here is how to use Queue\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Spotlibs\\PhpLib\\Facades\\Queue;\nuse App\\Jobs\\SendMoney;\nuse App\\Models\\Employee;\n\nclass Payday\n{\n    public function index(Request $request): void\n    {\n        $employees = Employee::get();\n        foreach ($employees as $employee) {\n            Queue::pushOn('payday', new SendMoney());\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotlibs%2Fphp-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspotlibs%2Fphp-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotlibs%2Fphp-lib/lists"}