Download the PHP package kazistm/algeria-geo without Composer

On this page you can find all versions of the php package kazistm/algeria-geo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package algeria-geo

Algeria Geo Data for Laravel by KaziSTM

Latest Version on Packagist Total Downloads License Laravel Compatibility

🇩🇿 Algeria Administrative Update

This package fully supports Algeria’s latest administrative division:

Unlike many existing packages, this dataset reflects the latest official Algerian administrative structure.


Table of Contents


Features

Installation

1. Require Package

Install the package via Composer:

2. Run Install Command

This command checks if the tables exist, runs the migrations if needed, and optionally seeds the database.

Bash

The command will inform you if the tables already exist and skip the process unless --force is used.

3. Optional Publishing

You typically don't need to publish assets, as the package runs migrations directly from its vendor directory.
However, if you need deep customization:

Bash

Usage

Models

Access the models using their namespaces:

City (Wilaya)

Represents an Algerian Wilaya.

Column Type Description
id Primary Key Unique identifier
code int Wilaya code (e.g., 16)
name string Wilaya name (e.g., "Alger")
arabic_name string Wilaya name in Arabic (e.g., "الجزائر")
slug string Unique slug (e.g., "algiers")
longitude float | null Optional longitude
latitude float | null Optional latitude
created_at timestamp Timestamp
updated_at timestamp Timestamp

Commune (Daira)

Represents an Algerian Commune (Daira).

Column Type Description
id Primary Key Unique identifier
post_code string | null Postal code (nullable)
name string Commune name
wilaya_id int Foreign key to cities.id
arabic_name string Commune name in Arabic
slug string Unique per Wilaya (used for lookup & URLs)
longitude float | null Optional longitude
latitude float | null Optional latitude
distance float | null Available after using withinRadius scope
created_at timestamp Timestamp
updated_at timestamp Timestamp

⚠️ Note: A unique constraint is enforced on (wilaya_id, slug) to prevent duplicates.

Basic Retrieval

Relationships

City to Communes

Commune to City

Static Finders

Convenient methods to find a single record by a specific attribute.

City::findByCode()

Finds a City (Wilaya) by its official code.

Commune::findByPostCode()

Finds the first Commune matching the given postal code.
Note: Postal codes might not be strictly unique across all communes in some datasets.

searchByName()

Available on both City and Commune. Searches the name and arabic_name columns.

code() (City)

Filters Cities by their official code.

postCode() (Commune)

Filters Communes by their postal code.

withinRadius() (Commune)

Finds Communes within a specified radius of a given latitude/longitude point using the Haversine formula.

Parameters:

Returns:

Example (Kilometers):

withinRadius() (Commune)

Finds Communes within a specified radius of a given latitude/longitude point using the Haversine formula.

Parameters:

Returns:

Example (Kilometers):

Note: This query relies on the latitude and longitude columns being populated in your communes table. Accuracy depends on the quality of the coordinate data. Communes with NULL coordinates are automatically excluded from the radius search.


City::findBySlug()

Finds a City (Wilaya) by its slug.

`

Commune::findBySlu()

Finds a Commune by its slug.

`


Helper Methods

Instance methods available on retrieved models.

getCoordinates()

Available on both City and Commune. Returns coordinates as an associative array or null.

PHP Example:

getDisplayName()

Available on both City and Commune. Returns the name, optionally preferring the Arabic name.

PHP Example:


Data Source

The dataset has been fully updated to reflect Algeria’s latest administrative divisions (69 Wilayas).

Improvements:

The seeders are designed to be:


Testing

This package includes a comprehensive test suite built with Pest.

Coverage

Test coverage is maintained at >95% to ensure stability and reliability.

Run tests

Run coverage

Contributing

Contributions (bug reports, feature requests, pull requests) are welcome. Please refer to the GitHub repository issues and pull request sections.


License

This package is open-source software licensed under the MIT license.



All versions of algeria-geo with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5
illuminate/console Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/filesystem Version ^10.0 || ^11.0 || ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kazistm/algeria-geo contains the following files

Loading the files please wait ...