Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Geography Laravel Package

lyssal/geography

Lyssal Geography offers a reusable PHP geography model for managing countries, regions, and cities. It helps structure hierarchical location data and integrate geographic entities into applications, making it easier to store, query, and present consistent location information.

View on GitHub
Deep Wiki
Context7

A PHP geographic library.

Frequently asked questions about Geography
What is lyssal/geography used for?
Lyssal Geography is a PHP package for modeling and managing geographical data such as countries, regions, and localities. It provides reusable structures for administrative areas and the relationships between them, so you do not have to rebuild geography models in every project. It is framework-agnostic and includes Doctrine ORM integration for persistence and querying.
How do I install lyssal/geography with Composer?
Install it with composer require lyssal/geography. Because persistence is handled through Doctrine ORM, you also need Doctrine configured in your application along with the entity mapping setup described in the repository. Check the README for the supported PHP version and any optional dependencies before wiring it into an existing project.
Can I use lyssal/geography in a Laravel application?
Yes, it is plain PHP and can be pulled in through Composer, but be aware that it is not built around Eloquent. The geography models are Doctrine entities, so a Laravel app needs Doctrine ORM integration, for example a Doctrine bridge package, rather than Laravel's default Eloquent setup. If your app is Eloquent-only, weigh that extra configuration against writing your own simple models.
Does lyssal/geography use Eloquent or Doctrine ORM?
It uses Doctrine ORM. The package supplies entity mappings and relationship mapping between geographic entities so they can be persisted and queried. Laravel developers who want Eloquent models would need to wrap the package's structures or map them to their own Eloquent models.
How are countries, regions, and cities related in lyssal/geography?
The package models them hierarchically: countries contain regions, and regions contain localities. Relationship mapping between the entities lets you traverse from a locality up to its region and country, or list the children of a given administrative area. The exact association names and cardinalities are defined in the package's Doctrine mappings, so review those before writing queries.
Do I need a database to use lyssal/geography?
Persistence is provided through Doctrine ORM, so storing and querying entities requires a database plus Doctrine configuration. You can use the model classes in memory without a database, but you lose the storage and querying benefits that are the main reason to adopt the package. In practice most applications pair it with a relational database such as MySQL, PostgreSQL, or SQLite.
Can I add custom fields like ISO codes or coordinates to the geography models?
The models are ordinary PHP classes mapped with Doctrine, so the usual approach is to extend them or map additional properties in your own subclasses. Doctrine inheritance mapping lets you add fields such as ISO codes, postal codes, or latitude and longitude without forking the package. Confirm the supported mapping strategy in the package documentation first, since changing mappings affects your schema.
Does lyssal/geography ship with a dataset of countries and cities?
The package focuses on the models and relationships, not on shipping a complete ready-made dataset of every country and city. Seeding your own data, for example from an open geographic dataset, into the Doctrine entities is typically part of the integration work. Check the repository for any fixtures or import tooling before assuming data is included.
How does lyssal/geography compare to packages like rinvex/countries?
They solve different problems. Country-list packages focus on static reference data such as names, ISO codes, currencies, and phone prefixes, while lyssal/geography focuses on hierarchical entity models for countries, regions, and localities with Doctrine persistence. The two can be complementary: use a data package as a seed source and Lyssal Geography for the structure and relationships. Choose based on whether you need storage and relationships or just lookup data.
How should I test code that uses lyssal/geography?
Because the models are plain Doctrine entities, you can instantiate countries, regions, and localities directly in unit tests without touching a database. For persistence and relationship tests, use an in-memory SQLite database with Doctrine's schema tool so the mappings are exercised realistically. Keep fixtures small and assert on relationships rather than hard-coded identifiers.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo