Download the PHP
package alrez/iran-states without Composer
On this page you can find all versions of the php package
alrez/iran-states. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
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.
[](https://opensource.org/licenses/MIT)
[](https://www.php.net/)
[](https://laravel.com)
## درباره پکیج
این پکیج برای مدیریت استانها و شهرهای ایران در فریمورک لاراول طراحی شده است. با استفاده از این پکیج میتوانید به راحتی به لیست استانها و شهرهای ایران دسترسی داشته باشید.
## ویژگیهای جدید
- سازگار با Laravel 11 و 12
- Seeder بهینه شده با استفاده از chunk(1000)
- دو trait جدید برای مدیریت روابط
- Service بهینه شده با cache بهتر
- Type hints کامل برای PHP 8.2+
## نصب
برای نصب از طریق کامپوزر:
سپس برای نصب جداول و دادههای پایه:
این دستور به صورت خودکار مایگریشنها را اجرا کرده و دادههای پایه را در دیتابیس وارد میکند.
## انتشار فایلهای پکیج (اختیاری)
برای انتشار فایل کانفیگ:
## استفاده
### مدلها با Traits جدید
#### مدل City با InteractWithState
#### مدل State با InteractWithStates
### استفاده از Traits در مدلهای شخصی
#### برای مدلهایی که به یک استان تعلق دارند
#### برای مدلهایی که با چندین استان کار میکنند
### سرویس بهینه شده
### قوانین اعتبارسنجی
## نکات عملکرد
### Cache
- تمام عملیات اصلی cache شدهاند (24 ساعت)
- برای پاک کردن cache از `clearCache()` استفاده کنید
- عملیات جستجو cache نمیشوند
### انتخاب متد مناسب
- برای dropdown کامل: `getAllStatesWithCities()`
- برای یک استان خاص: `getStateById()`
- برای شهرهای یک استان: `getCitiesByStateId()`
- برای عملیات چندتایی: `getStatesByIds()` یا `getCitiesByStateIds()`
Iran States Package for Laravel
About
This package provides a comprehensive solution for managing Iran's states and cities in Laravel applications. It offers easy access to a complete list of Iran's states and their corresponding cities with improved performance and modern Laravel features.
New Features
Compatible with Laravel 11 & 12
Optimized seeders using chunk(1000)
Two new traits for relationship management
Enhanced service with better caching
Full type hints for PHP 8.2+
Installation
Install via Composer:
Then install the tables and seed the data:
This command will automatically run the migrations and seed the database with the initial data using optimized chunked insertion.
Publishing Package Files (Optional)
To publish the config file:
Usage
Models with New Traits
City Model with InteractWithState
State Model with InteractWithStates
Using Traits in Your Own Models
For models that belong to a single state
For models that work with multiple states
Enhanced Service
Validation Rules
Performance Notes
Caching
All main operations are cached (24 hours)
Use clearCache() to clear cache when needed
Search operations are not cached
Choosing the Right Method
For complete dropdown: getAllStatesWithCities()
For specific state: getStateById()
For cities of a state: getCitiesByStateId()
For batch operations: getStatesByIds() or getCitiesByStateIds()
Requirements
PHP 8.2 or higher
Laravel 11.x or 12.x
License
MIT License. Please see License File for more information.
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 alrez/iran-states contains the following files
Loading the files please wait ....
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.