This is an example of using a PSR-4 autoloader with phpspec.
In your Composer PSR-4 autoloader, make sure the namespace is consistent with the namespace
and psr-4_prefix
settings for your test suite in your phpspec.yml
file. Review those files in this repository for an example.
composer global require phpspec/phpspec
Example output:
Changed current directory to ~/.composer
Using version ^2.5 for phpspec/phpspec
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
composer install
Example output:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
phpspec describe Acme/Text/Markdown
Example output:
Specification for Acme\Text\Markdown created in spec/MarkdownSpec.php.
phpspec run
Example output:
Acme/Text/Markdown
10 - it is initializable
class Acme\Text\Markdown does not exist.
100% 1
1 specs
1 example (1 broken)
14ms
Do you want me to create `Acme\Text\Markdown` for you?
[Y/n] y
Class Acme\Text\Markdown created in src/Markdown.php.
100% 1
1 specs
1 example (1 passed)
11ms