In 2019 I needed division, district, and upazila data for a Laravel app. I had already created the same tables and imported the same Bangladesh location data in earlier projects. That was the reason I put the migrations, seeders, and models into a PHP package. Seven years later, I can install that data with Cargo and use it from a Rust handler. My original blog post · The PHP package
On December 1, Laravel released the first beta of Laravel Rust. One detail I like as a package author is that a model can expose a relationship as a Rust method. Once I have a Division, I can call division.districts() and work with district records. The database query is asynchronous, and the compiler knows which fields belong to a district. Laravel Rust release announcement
Install the crate
I released laravel-bangladesh-geocode on crates.io with the original numeric IDs and the English and Bangla names from the PHP package. It includes divisions, districts, upazilas, unions, and post offices. The original division, district, and upazila data came from Nuhil Mehdy. Rust package · Original dataset
From a Laravel Rust project using Rust 1.99 or newer, add the crate.
cargo add laravel-bangladesh-geocode
In src/app.rs, import laravel_bangladesh_geocode::BangladeshGeocodeServiceProvider and add providers.add(BangladeshGeocodeServiceProvider); inside the application builder’s .with_providers(...) closure. Once your database connection and its matching Cargo feature are configured, run the package migrations and seed all five tables with one command.
cargo run -- BangladeshGeocode:setup
Follow an address from Chattagram to Subil
I built a small example app with MySQL, Inertia, and React. Once you have it running, open /locations and choose Chattagram → Comilla → Debidwar → Subil. The page displays the address in mailing order, Subil, Debidwar, Comilla, Chattagram, and shows the Bangla names alongside the English ones. Run the Rust example app
The first response only needs eight divisions. When you choose Comilla, the browser asks for that district’s upazilas. When you choose Debidwar, it asks for that upazila’s unions. Try switching the division to Dhaka after selecting Subil. The form clears the old district, upazila, and union together, so an address in Dhaka can’t accidentally retain a union from Comilla. You can follow one of those requests from the route to the relationship query in the Rust location handlers.