PHPackages                             palpalani/baylinks-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. palpalani/baylinks-laravel

ActiveLibrary[Framework](/categories/framework)

palpalani/baylinks-laravel
==========================

PHP/Laravel framework SDK for BayLinks.

v0.5.0(6mo ago)25.2k↓50%[2 issues](https://github.com/palpalani/baylinks-laravel/issues)MITPHPPHP ^8.3CI passing

Since Jul 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/palpalani/baylinks-laravel)[ Packagist](https://packagist.org/packages/palpalani/baylinks-laravel)[ Docs](https://github.com/palpalani/baylinks-laravel)[ RSS](/packages/palpalani-baylinks-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (20)Used By (0)

BayLinks Laravel
================

[](#baylinks-laravel)

**A modern, type-safe Laravel SDK for the BayLinks URL shortening platform**

[![Latest Version on Packagist](https://camo.githubusercontent.com/080886913f837dee6b844b19265673cc211939e6652739dbeadb7be298417d1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70616c70616c616e692f6261796c696e6b732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/palpalani/baylinks-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1977b8ee3fc4158e2ff18f308a054d3e0aee670497a776545fe30b94e2fd2d74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6261796c696e6b732d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/palpalani/baylinks-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![PHPStan](https://camo.githubusercontent.com/1b83422b312e698e7e45cc326cf1a4d54c8a34c85f8e3b953b3b019efb313402/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6261796c696e6b732d6c61726176656c2f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/palpalani/baylinks-laravel/actions?query=workflow%3Aphpstan+branch%3Amain)[![Code Coverage](https://camo.githubusercontent.com/bb47fecc81f67b0c24640680c6727f0b5f5e3c197459c738f55eae74a389f2d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6261796c696e6b732d6c61726176656c2f636f7665726167652e796d6c3f6272616e63683d6d61696e266c6162656c3d636f766572616765267374796c653d666c61742d737175617265)](https://github.com/palpalani/baylinks-laravel/actions?query=workflow%3A%22Code+Coverage%22+branch%3Amain)[![Security Scan](https://camo.githubusercontent.com/500a960766dc5ca5f761e77f1a213d5131d2d2fe28bc45b19c99f2f972d67485/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6261796c696e6b732d6c61726176656c2f73656375726974792e796d6c3f6272616e63683d6d61696e266c6162656c3d7365637572697479267374796c653d666c61742d737175617265)](https://github.com/palpalani/baylinks-laravel/actions?query=workflow%3A%22Security+Scan%22+branch%3Amain)[![Code Style](https://camo.githubusercontent.com/06ca628d11b099859a525172d6ca6aaccb6651c5e6680fde804342eed37a52be/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70616c70616c616e692f6261796c696e6b732d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/palpalani/baylinks-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)

[![Total Downloads](https://camo.githubusercontent.com/5c7296ee957898856b02f94dff46c5b4c5aa49cc4bc850c626bee085c03b90f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70616c70616c616e692f6261796c696e6b732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/palpalani/baylinks-laravel)[![PHP Version](https://camo.githubusercontent.com/c2409889d988afa08eaa38257f530e8d573548e577701dd4ed2d65a172f95159/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70616c70616c616e692f6261796c696e6b732d6c61726176656c3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/palpalani/baylinks-laravel)[![Laravel Version](https://camo.githubusercontent.com/f002ff4a2256ffcb0be8275519086e42196dae3482e3d466f7f04d7678ab005a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3130253230253743253230313125323025374325323031322d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://laravel.com)[![License](https://camo.githubusercontent.com/d3e28622724c557290c1a0db305aa79e7dfd67a2e4b41ff66b120bfa46c9efa7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70616c70616c616e692f6261796c696e6b732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

[Features](#features) • [Installation](#installation) • [Usage](#usage) • [API Reference](#api-reference) • [Contributing](#contributing)

---

About
-----

[](#about)

This Laravel package provides an elegant, fluent interface to the [BayLinks](https://baylinks.io) API - a powerful URL shortening and management platform for modern businesses. Built on top of [Saloon PHP](https://docs.saloon.dev/), this SDK offers type-safe request/response handling, robust error management, and seamless Laravel integration.

Features
--------

[](#features)

- **🎯 Type-Safe**: Full PHP 8.3+ type safety with PHPStan level 4 analysis
- **🚀 Modern Architecture**: Built on Saloon PHP for elegant HTTP client abstraction
- **🔒 Secure**: Per-request API key authentication with built-in error handling
- **🧪 Well-Tested**: Comprehensive test suite with Pest PHP
- **📦 Laravel Native**: First-class Laravel integration with service provider and facade
- **🔄 Bulk Operations**: Support for bulk URL creation and management
- **📊 Analytics**: Track URL visit records and performance metrics
- **🎨 PSR Compliant**: Follows PSR-1, PSR-2, and PSR-12 coding standards

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 10.x, 11.x, or 12.x
- Composer 2.x

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require palpalani/baylinks-laravel
```

### Configuration

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="baylinks-laravel-config"
```

This creates `config/baylinks-laravel.php` with the following structure:

```
return [
    'server' => env('BAYLINKS_SERVER'),

    'api' => [
        'url' => 'api/v1',
        'key' => env('BAYLINKS_API_KEY'),
        'secret' => env('BAYLINKS_API_SECRET'),
    ],
];
```

Update your `.env` file:

```
BAYLINKS_SERVER=https://baylinks.io
BAYLINKS_API_KEY=your_api_key_here
BAYLINKS_API_SECRET=your_api_secret_here
```

Usage
-----

[](#usage)

### Basic Examples

[](#basic-examples)

#### Retrieve Account Information

[](#retrieve-account-information)

```
use PalPalani\BayLinks\Facades\BayLinks;

$client = BayLinks::client();
$account = $client->accountDetails()->get('your_api_key');
```

#### Create a Single Short URL

[](#create-a-single-short-url)

```
use PalPalani\BayLinks\Facades\BayLinks;

$client = BayLinks::client();

$shortUrl = $client->createShortURL()->post('your_api_key', [
    'destination' => 'https://example.com/very-long-url',
    'domain' => 'custom.domain.com', // optional
]);
```

#### Create Multiple Short URLs (Bulk)

[](#create-multiple-short-urls-bulk)

```
use PalPalani\BayLinks\Facades\BayLinks;

$client = BayLinks::client();

$bulkUrls = $client->createBulkURL()->post('your_api_key', [
    'destination' => [
        'https://example.com/page-1',
        'https://example.com/page-2',
        'https://example.com/page-3',
    ],
    'domain' => 'custom.domain.com', // optional
    'planet' => 'jupiter', // optional
    'expire' => 0, // optional (0 = never expires)
    'tag' => ['campaign' => 'summer-2024'], // optional metadata
]);
```

### Advanced Usage

[](#advanced-usage)

#### Update Short URL Status

[](#update-short-url-status)

```
$client = BayLinks::client();

$response = $client->updateShortURLStatus()->post('your_api_key', [
    'url_id' => 'abc123',
    'status' => 'inactive',
]);
```

#### Retrieve Visit Records

[](#retrieve-visit-records)

```
$client = BayLinks::client();

$visitRecords = $client->ShortUrlVisitRecord()->post('your_api_key', [
    'url_id' => 'abc123',
    'from_date' => '2024-01-01',
    'to_date' => '2024-12-31',
]);
```

#### Using Dependency Injection

[](#using-dependency-injection)

```
use PalPalani\BayLinks\Factory;

class UrlShortenerService
{
    public function __construct(
        private Factory $bayLinks
    ) {}

    public function shortenUrl(string $url, string $apiKey): mixed
    {
        return $this->bayLinks
            ->createShortURL()
            ->post($apiKey, ['destination' => $url]);
    }
}
```

#### Error Handling

[](#error-handling)

```
use Saloon\Exceptions\Request\FatalRequestException;
use Saloon\Exceptions\Request\RequestException;

try {
    $shortUrl = BayLinks::client()
        ->createShortURL()
        ->post('your_api_key', [
            'destination' => 'https://example.com',
        ]);
} catch (FatalRequestException $e) {
    // Handle fatal errors (network issues, timeouts, etc.)
    Log::error('BayLinks fatal error: ' . $e->getMessage());
} catch (RequestException $e) {
    // Handle API errors (validation, authentication, etc.)
    Log::error('BayLinks API error: ' . $e->getMessage());

    // Access response details
    $statusCode = $e->getStatus();
    $responseBody = $e->getResponse()->body();
}
```

API Reference
-------------

[](#api-reference)

### Client Initialization

[](#client-initialization)

```
use PalPalani\BayLinks\Facades\BayLinks;

$client = BayLinks::client();
// or
$client = BayLinks::factory();
```

### Available Methods

[](#available-methods)

#### Account Operations

[](#account-operations)

MethodDescriptionParameters`accountDetails()->get($apiKey)`Retrieve account information`string $apiKey`#### URL Operations

[](#url-operations)

MethodDescriptionParameters`createShortURL()->post($apiKey, $data)`Create a single short URL`string $apiKey`, `array $data``createBulkURL()->post($apiKey, $data)`Create multiple short URLs`string $apiKey`, `array $data``updateShortURLStatus()->post($apiKey, $data)`Update URL status`string $apiKey`, `array $data``ShortUrlVisitRecord()->post($apiKey, $data)`Get visit analytics`string $apiKey`, `array $data`### Request Payload Schemas

[](#request-payload-schemas)

#### Create Short URL

[](#create-short-url)

```
[
    'destination' => 'https://example.com/page',  // required
    'domain' => 'custom.domain.com',              // optional
]
```

#### Create Bulk URLs

[](#create-bulk-urls)

```
[
    'destination' => [                              // required (array of URLs)
        'https://example.com/page-1',
        'https://example.com/page-2',
    ],
    'domain' => 'custom.domain.com',               // optional
    'planet' => 'jupiter',                         // optional
    'expire' => 0,                                 // optional (seconds, 0 = never)
    'tag' => ['key' => 'value'],                   // optional (metadata)
]
```

Testing
-------

[](#testing)

Run the full test suite with Pest:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Run specific test file:

```
vendor/bin/pest tests/ExampleTest.php
```

Run tests with filtering:

```
vendor/bin/pest --filter=CanCreateShortUrl
```

### Code Quality

[](#code-quality)

Run PHPStan static analysis:

```
composer analyse
```

Format code with Laravel Pint:

```
composer format
```

Development
-----------

[](#development)

### Architecture

[](#architecture)

This package uses [Saloon PHP](https://docs.saloon.dev/) for HTTP client abstraction:

- **Factory**: Main connector extending `Saloon\Http\Connector`
- **Resources**: Group related API endpoints (`AccountResource`, `CreateShortURLResource`)
- **Requests**: Individual API requests extending `Saloon\Http\Request`
- **Responses**: Transform API responses to DTOs
- **Objects**: Immutable data transfer objects

### Adding New Endpoints

[](#adding-new-endpoints)

1. Create a new Request class in `src/Requests/{Category}/`
2. Create a corresponding Response class in `src/Responses/{Category}/`
3. Add a Resource method or create new Resource in `src/Resources/`
4. Update the Factory with a new resource method if needed
5. Write tests in `tests/`

See [CLAUDE.md](CLAUDE.md) for detailed development guidelines.

### Continuous Integration

[](#continuous-integration)

This package uses GitHub Actions for automated testing and quality checks:

WorkflowPurposeTrigger**Tests**Run Pest tests across PHP 8.3-8.4, Laravel 11-12, Ubuntu/WindowsPush, PR**PHPStan**Static analysis at level 4Push, PR**Code Coverage**Track test coverage with CodecovPush, PR**Security Scan**Composer audit, dependency review, SBOM generationPush, PR, Weekly**Code Style**Auto-fix with Laravel PintPush (branches only)**PR Quality**Validate composer.json, check for debug statementsPR onlyAll workflows use Composer caching for faster builds and concurrency controls to prevent redundant runs.

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

#### "Class 'BayLinks' not found"

[](#class-baylinks-not-found)

Make sure you've published the service provider:

```
php artisan config:clear
php artisan cache:clear
composer dump-autoload
```

#### Authentication Errors

[](#authentication-errors)

Verify your API key is correct and active:

```
// Test connection
try {
    $account = BayLinks::client()->accountDetails()->get('your_api_key');
    dump($account);
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

#### SSL Certificate Issues

[](#ssl-certificate-issues)

If you encounter SSL errors in development:

```
// In config/baylinks-laravel.php (development only!)
// Note: Never disable SSL verification in production
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes and version history.

Contributing
------------

[](#contributing)

We welcome contributions! Here's how you can help:

### Getting Started

[](#getting-started)

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/my-new-feature`
3. Make your changes and commit: `git commit -am 'Add new feature'`
4. Push to the branch: `git push origin feature/my-new-feature`
5. Submit a pull request

### Development Guidelines

[](#development-guidelines)

- Follow PSR-1, PSR-2, and PSR-12 coding standards
- Write tests for new features (we use Pest)
- Ensure PHPStan passes at level 4: `composer analyse`
- Format code with Pint: `composer format`
- Update documentation for API changes
- Add entries to CHANGELOG.md

### Running Tests

[](#running-tests)

```
# Install dependencies
composer install

# Run tests
composer test

# Run static analysis
composer analyse

# Format code
composer format
```

### Pull Request Checklist

[](#pull-request-checklist)

- Tests pass (`composer test`)
- Static analysis passes (`composer analyse`)
- Code is formatted (`composer format`)
- Documentation is updated
- CHANGELOG.md is updated

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Credits
-------

[](#credits)

- **[palPalani](https://github.com/palpalani)** - Creator &amp; Maintainer
- **[Prasanth](mailto:prasanth.s@targetbay.com)** - Core Developer
- **[All Contributors](../../contributors)** - Community Contributors

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---

**[⬆ Back to Top](#baylinks-laravel)**

Made with ❤️ by [palPalani](https://github.com/palpalani)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance60

Regular maintenance activity

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Recently: every ~141 days

Total

10

Last Release

189d ago

PHP version history (4 changes)v0.1.0PHP ^8.1

v0.1.2PHP ^8.0

v0.2.0PHP ^8.2

v0.4.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/716695?v=4)[Palaniappan P](/maintainers/palpalani)[@palpalani](https://github.com/palpalani)

---

Top Contributors

[![palpalani](https://avatars.githubusercontent.com/u/716695?v=4)](https://github.com/palpalani "palpalani (133 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (59 commits)")[![prasantargetbay](https://avatars.githubusercontent.com/u/121081197?v=4)](https://github.com/prasantargetbay "prasantargetbay (16 commits)")[![cvinoth-kumar](https://avatars.githubusercontent.com/u/143263380?v=4)](https://github.com/cvinoth-kumar "cvinoth-kumar (2 commits)")[![prasanthdk](https://avatars.githubusercontent.com/u/41140776?v=4)](https://github.com/prasanthdk "prasanthdk (2 commits)")

---

Tags

laravelpalpalanibaylinks-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/palpalani-baylinks-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/palpalani-baylinks-laravel/health.svg)](https://phpackages.com/packages/palpalani-baylinks-laravel)
```

###  Alternatives

[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

17959.0k](/packages/lunarstorm-laravel-ddd)[bezhansalleh/filament-plugin-essentials

A collection of essential traits that streamline Filament plugin development by taking care of the boilerplate, so you can focus on shipping real features faster

27584.7k16](/packages/bezhansalleh-filament-plugin-essentials)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[jonpurvis/squeaky

A Laravel Validation Rule to Help Catch Profanity.

706.0k](/packages/jonpurvis-squeaky)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
