PHPackages                             wnx/faker-swiss-locations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wnx/faker-swiss-locations

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wnx/faker-swiss-locations
=========================

Provider to generate valid Swiss location data for Faker PHP.

v1.4.0(5mo ago)33.6kMITPHPPHP ^8.4CI passing

Since Apr 19Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/stefanzweifel/faker-swiss-locations)[ Packagist](https://packagist.org/packages/wnx/faker-swiss-locations)[ Docs](https://github.com/stefanzweifel/faker-swiss-locations)[ GitHub Sponsors](https://github.com/stefanzweifel)[ RSS](/packages/wnx-faker-swiss-locations/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (9)Used By (0)

faker-swiss-locations
=====================

[](#faker-swiss-locations)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2b1046cdf5870d46f5003d67e85cbffc08d31c6858b65e6f5ed00953476bedb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776e782f66616b65722d73776973732d6c6f636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/faker-swiss-locations)[![Tests](https://github.com/stefanzweifel/faker-swiss-locations/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/stefanzweifel/faker-swiss-locations/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/038eae77eb13ac9a755a4f2009207a8451c6aea324af5937966d18af2ff9d093/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776e782f66616b65722d73776973732d6c6f636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/faker-swiss-locations)

Faker provider to generate random valid Swiss locations.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require wnx/faker-swiss-locations
```

Usage
-----

[](#usage)

You first need to add the `Location` provider to Faker.

```
// Add Location Provider to Faker
$faker = Factory::create();
$faker->addProvider(new Wnx\FakerSwissLocations\Provider\Location($faker));
```

You can now call the `postcode()`, `city()` or `canton()` method on faker to get a random valid Swiss location.

> **Note**Calling `postcode()`, `city()` or `canton()` always returns a new random location. If you need the same location for `postcode`, `city` and `canton` use the `location()`-method and access the properties from the instance.

```
// 8000
$faker->postcode();

// Zürich
$faker->city();

// Instance of Wnx\SwissCantons\Canton
$faker->canton();
$faker->canton()->getName(); // Zürich
$faker->canton()->getAbbreviation(); // ZH
```

Or you can call the `location()` method to get a `\Wnx\FakerSwissLocations\Location`-instance. You can access postcode, city and canton from this object too.

```
// Instance of \Wnx\FakerSwissLocations\Location
$location = $faker->location();

$location->postcode; // 8000
$location->city; // Zürich
$location->canton; // Instance of Wnx\SwissCantons\Canton
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan Zweifel](https://github.com/stefanzweifel)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance81

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 63.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~189 days

Recently: every ~233 days

Total

6

Last Release

170d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.4.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6e76cb0a5ed6788731857a8b4e1a27e283cef831fe42bf9636549bf9b35ddd7?d=identicon)[stefanzweifel](/maintainers/stefanzweifel)

---

Top Contributors

[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (57 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (21 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

fakerwnxcitiesswitzerlandFake dataswiss

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wnx-faker-swiss-locations/health.svg)

```
[![Health](https://phpackages.com/badges/wnx-faker-swiss-locations/health.svg)](https://phpackages.com/packages/wnx-faker-swiss-locations)
```

###  Alternatives

[mbezhanov/faker-provider-collection

A collection of custom providers for the Faker library

2138.6M24](/packages/mbezhanov-faker-provider-collection)[pelmered/fake-car

Fake-Car is a Faker provider that generates fake car data for you.

1271.2M2](/packages/pelmered-fake-car)[mmo/faker-images

Different images provider for Faker

59370.3k6](/packages/mmo-faker-images)[smknstd/fakerphp-picsum-images

Alternative image provider for fakerphp using picsum.photos

45218.1k3](/packages/smknstd-fakerphp-picsum-images)[bluemmb/faker-picsum-photos-provider

picsum.photos provider for Faker

31225.7k1](/packages/bluemmb-faker-picsum-photos-provider)[aalaap/faker-youtube

Faker provider for generating fake YouTube video URLs

2288.6k](/packages/aalaap-faker-youtube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
