1. Go to this page and download the library: Download yivoff/spanish-nif library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yivoff / spanish-nif example snippets
$checker = new \Yivoff\NifCheck\NifChecker();
// returns true if valid
$checker->verify($anyNif);
$generator = new \Yivoff\NifCheck\Generator\RandomNif();
// Generates a valid DNI
$validDni = $generator->generateDni();
// Generates a valid NIE
$validNie = $generator->generateNie();
// Generates a valid CIF
$validCif = $generator->generateCif();
// Generates a valid NIF (randomly DNI, NIF, or CIF)
$validNif = $generator->generate();
use Yivoff\NifCheck\Validator\ValidNif;
class User
{
#[ValidNif]
public string $nif;
}
$faker = Faker\Factory::create();
$faker->addProvider(new \Yivoff\NifCheck\FakerProvider\NifProvider($faker, new \Yivoff\NifCheck\Generator\RandomNif()));
// now you can fake NIFs
$faker->spanishDni();
$faker->spanishNie();
$faker->spanishCif();
$faker->spanishNif();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.