Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cherifgsoul/php-algerian-mobile-phone-number-doctrine
Ability to Use cherif/php-algerian-mobile-phone-number as Doctrine ORM field type
https://github.com/cherifgsoul/php-algerian-mobile-phone-number-doctrine
algeria algeria-phone-number doctrine-orm hacktoberfest hacktoberfest2022 laminas-mvc laravel-doctrine php symfony types
Last synced: about 1 month ago
JSON representation
Ability to Use cherif/php-algerian-mobile-phone-number as Doctrine ORM field type
- Host: GitHub
- URL: https://github.com/cherifgsoul/php-algerian-mobile-phone-number-doctrine
- Owner: cherifGsoul
- License: mit
- Created: 2020-09-16T15:26:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-16T15:42:07.000Z (over 4 years ago)
- Last Synced: 2024-04-17T05:34:53.297Z (8 months ago)
- Topics: algeria, algeria-phone-number, doctrine-orm, hacktoberfest, hacktoberfest2022, laminas-mvc, laravel-doctrine, php, symfony, types
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cherif/php-algerian-mobile-phone-number-doctrine
The cherif/php-algerian-mobile-phone-number-doctrine package allows to use [cherif/algerian-mobile-phone-number](https://github.com/cherifGsoul/php-algerian-mobile-phone-number) as a [Doctrine field type](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/custom-mapping-types.html).
## Installtion
The recommended way of installation is by using [Packagist](https://packagist.org/packages/cherif/php-algerian-mobile-phone-number-doctrine) and [Composer](http://getcomposer.org/).The following command should be executed in order to add the package as a requirement to `composer.json` of a project:
```shell
$ composer require cherif/php-algerian-mobile-phone-number-doctrine
```## Examples:
To configure Doctrine to use cherif/php-algerian-mobile-phone-number-doctrine as a field type, you'll need to set up the following in your bootstrap:```php
\Doctrine\DBAL\Types\Type::addType('algerian_mobile_phone_number', 'Cherif\AlgerianMobilePhoneNumber\Doctrine\AlgerianMobilePhoneNumberType');
```In Symfony:
```yaml
# config/packages/doctrine.yaml
doctrine:
dbal:
types:
algerian_mobile_phone_number: Cherif\AlgerianMobilePhoneNumber\Doctrine\AlgerianMobilePhoneNumberType
```
## Usage:Then, in your entities, you may annotate properties by setting the @Column type to `algerian_mobile_phone_number`:
```php
use Doctrine\ORM\Mapping as ORM;
use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber;/**
* @ORM\Entity
* @ORM\Table(name="person")
*/
class Person
{
/**
* @var Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber
*
* @ORM\Id
* @ORM\Column(type="algerian_mobile_phone_number", unique=true)
*/
protected $mobilePhoneNumber;public function getMobilePhoneNumber(): AlgerianMobilePhoneNumber
{
return $this->mobilePhoneNumber;
}
}
```To use XML Mapping instead of PHP annotations.
```xml
......
```## Contribution
Contributions are welcome to make this library better.- Clone the repo:
```shell
$ git clone [email protected]:cherifGsoul/php-algerian-mobile-phone-number-doctrine.git
```and enter to the cloned repository directory.
- Install dependencies:
```shell
$ composer install
```### Testing:
Run composer script for testing:```shell
$ ./bin/phpunit
```## License
[MIT License](LICENSE).