PHPackages                             weblabormx/world - 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. [API Development](/categories/api)
4. /
5. weblabormx/world

AbandonedArchivedLibrary[API Development](/categories/api)

weblabormx/world
================

Weblabor World API Wrapper Library for PHP

1.0.6(4mo ago)04.0k↓31.6%1PHPPHP ^8.1

Since Dec 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/weblabormx/world)[ Packagist](https://packagist.org/packages/weblabormx/world)[ RSS](/packages/weblabormx-world/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (10)Used By (1)

Weblabor World
==============

[](#weblabor-world)

This is a PHP library to work with the World API.

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

[](#requirements)

- PHP 8.1 and later.

Packagist
---------

[](#packagist)

Install via packagist using:

```
composer require weblabormx/world

```

Don't forget to include the bindings:

```
require_once __DIR__ . '/vendor/autoload.php';
```

Initialize credentials
----------------------

[](#initialize-credentials)

You can choose to work with the library using the `World` static class like this:

```
use WeblaborMx\World\World;

// World::setApiBase("https://world.weblabor/api"); # Optionally set an alternative base
World::init(apiKey: "YOUR_API_KEY");

$client = World::getClient();

// Do stuff...
```

Or by instantiating a client object:

```
use WeblaborMx\World\Client;

$client = new Client(
    apiKey: 'YOUR_API_KEY',
    // apiBase: 'https://world.weblabor/api',
);

// Do stuff...
```

**The static way is recommended.**

Divisions
---------

[](#divisions)

The API works by getting the different levels of divisions of the world. Yoy may normally know them as countries, states and cities, but other nations call them different and have more than 3 levels.

So, the world is divided in different ways depending each different sovereign nation.

We normally call, the sovereign nations, the upmost level of division, countries. The children of the countries, states. And the children of those states, cities. This is the way the API is used, by traversing the different levels of divisions. A division has `children()` and `parent()` unless it's the upmost or downmost level of division.

### Properties

[](#properties)

All calls from the division endpoints, returns a `WeblaborMx\World\Entities\Division` object or array.

You can check the properties by inspecting the class constructor:

```
public function __construct(
    public int $id,
    public ?string $name = null,
    public ?string $country = null,
    public ?string $a1code = null,
    public ?string $level = null,
    public ?int $population = null,
    public ?float $lat = null,
    public ?float $long = null,
    public ?string $timezone = null,
    public ?int $parent_id = null,
) {
}
```

Endpoints
---------

[](#endpoints)

Check all endpoints in the [documentation](https://world.weblabor.mx/docs).

### Obtaining all countries

[](#obtaining-all-countries)

You probably want to start fetching divisions by their upmost level.

```
use WeblaborMx\World\World;
use WeblaborMx\World\Entities\Division;

$client = World::getClient();

/** @var Division[] **/
$countries = $client->makeCall('/countries');

foreach ($countries as $division) {
    echo $division->name . \PHP_EOL;
}
```

### Get country by code

[](#get-country-by-code)

You can search a country by its [ISO-3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) code.

```
use WeblaborMx\World\World;
use WeblaborMx\World\Entities\Division;

$client = World::getClient();

$code = "MX";

/** @var Division|null **/
$country = $client->makeCall("/country/{$code}");
```

### Getting a specific division

[](#getting-a-specific-division)

To get a specific division, you pass its previously obtained ID.

```
use WeblaborMx\World\Entities\Division;

$id = 3531011; // Probably want to obtain it from the DB

/** @var Division|null **/
$division = Division::get($id);
```

### Obtaining all children

[](#obtaining-all-children)

```
/** @var Division[] **/
$children = $division->children();
```

### Obtaining parent

[](#obtaining-parent)

```
/** @var Division|null **/
$parent = $division->parent();
```

Working with Laravel
--------------------

[](#working-with-laravel)

To maintain the library lightweight, no dependency was added. However, you can find a Division casting class, that although it doesn't implements the contract from Laravel, it should work as any other cast.

With the cast you can save any ID obtained in a model, and automatically obtain a `Division` when accesing the property again.

```
use Illuminate\Database\Eloquent\Model;
use WeblaborMx\World\Casts\DivisionCast;

class Company extends Model
{
    protected $casts = [
        'country' => DivisionCast::class,
        'state' => DivisionCast::class,
    ];

    // ...
}
```

### Registering client

[](#registering-client)

You probably want to initialize the client through a service provider like `AppServiceProvider`.

```
public function boot(): void
{
    // World::setApiBase(config('services.weblabor.world.endpoint'));
    World::init(apiKey: config('services.weblabor.world.token'));
}
```

Then setup the `services.php` configuration.

```
return [
    // ...
    'weblabor' => [
        'world' => [
            'endpoint' => env('WEBLABOR_WORLD_ENDPOINT', 'https://world.weblabor.mx/api'),
            'token' => env('WEBLABOR_WORLD_TOKEN'),
        ]
    ]
]
```

And the credentials in `.env`.

```
WEBLABOR_WORLD_ENDPOINT=
WEBLABOR_WORLD_TOKEN=

```

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance84

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~129 days

Recently: every ~193 days

Total

7

Last Release

148d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13341096?v=4)[Weblabor](/maintainers/weblabormx)[@weblabormx](https://github.com/weblabormx)

---

Top Contributors

[![LuanHimmlisch](https://avatars.githubusercontent.com/u/46875694?v=4)](https://github.com/LuanHimmlisch "LuanHimmlisch (12 commits)")[![skalero01](https://avatars.githubusercontent.com/u/2976641?v=4)](https://github.com/skalero01 "skalero01 (3 commits)")

### Embed Badge

![Health badge](/badges/weblabormx-world/health.svg)

```
[![Health](https://phpackages.com/badges/weblabormx-world/health.svg)](https://phpackages.com/packages/weblabormx-world)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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