Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Added some more information for autoloading in the readme #1780

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,29 @@ composer require fzaninotto/faker

## Basic Usage

Use `Faker\Factory::create()` to create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.
### Autoloading

Faker supports both `PSR-0` as `PSR-4` autoloaders.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if users care about the kind of autoloader we use internally.

Perhaps we should point out two options:

  • when installed via composer, require vendor/autoload.php
  • otherwise, require /path/to/Faker/src/autoload.php

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree but this is a bit "as is" and i think we should not just wipe it. The focus now is on composer autoload and otherwise the custom one which is psr0.

But i would not be suprised if there are enough people around that just load it manually instead and that do not use composer yet.

```php
<?php
# When installed via composer
require_once 'vendor/autoload.php';
```

You can also load `Fakers` shipped `PSR-0` autoloader
```php
<?php
// require the Faker autoloader
# Load Fakers own autoloader
require_once '/path/to/Faker/src/autoload.php';
// alternatively, use another PSR-4 compliant autoloader
```

*alternatively, you can use any another PSR-4 compliant autoloader*

### Create fake data
Use `Faker\Factory::create()` to create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.

```php
<?php
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();

Expand Down