PHP code example of wnx / faker-swiss-locations
1. Go to this page and download the library: Download wnx/faker-swiss-locations 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/ */
wnx / faker-swiss-locations example snippets
// Add Location Provider to Faker
$faker = Factory::create();
$faker->addProvider(new Wnx\FakerSwissLocations\Provider\Location($faker));
// 8000
$faker->postcode();
// Zürich
$faker->city();
// Instance of Wnx\SwissCantons\Canton
$faker->canton();
$faker->canton()->getName(); // Zürich
$faker->canton()->getAbbreviation(); // ZH
// Instance of \Wnx\FakerSwissLocations\Location
$location = $faker->location();
$location->postcode; // 8000
$location->city; // Zürich
$location->canton; // Instance of Wnx\SwissCantons\Canton