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

ActiveLibrary[API Development](/categories/api)

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

Weblabor World API Wrapper Library for PHP

1.0.6(3mo ago)01.4k↑20.7%1PHPPHP ^8.1

Since Dec 26Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (8)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

45

—

FairBetter than 93% of packages

Maintenance81

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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

102d 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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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