yiisoft / app-api
Yii3 API project template
Fund package maintenance!
Opencollective
yiisoft
Installs: 1 158
Dependents: 0
Suggesters: 0
Security: 0
Stars: 73
Watchers: 18
Forks: 28
Open Issues: 0
Type:project
pkg:composer/yiisoft/app-api
Requires
- php: ^8.2
- ext-filter: *
- httpsoft/http-message: ^1.1.6
- psr/container: ^2.0.2
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/log: ^3.0.2
- symfony/console: ^7.3.4
- yiisoft/aliases: ^3.1
- yiisoft/config: ^1.6
- yiisoft/data: ^1.0.1
- yiisoft/data-response: ^2.1.1
- yiisoft/definitions: ^3.4
- yiisoft/di: ^1.4
- yiisoft/error-handler: ^4.3
- yiisoft/http: ^1.2
- yiisoft/hydrator: ^1.6.2
- yiisoft/injector: ^1.2
- yiisoft/input-http: ^1.0.1
- yiisoft/log: ^2.1.1
- yiisoft/log-target-file: ^3.0
- yiisoft/middleware-dispatcher: ^5.3
- yiisoft/request-body-parser: ^1.2.0
- yiisoft/request-provider: ^1.2
- yiisoft/router: ^4.0.1
- yiisoft/router-fastroute: ^4.0.2
- yiisoft/validator: ^2.5
- yiisoft/yii-console: ^2.4
- yiisoft/yii-http: ^1.1.0
- yiisoft/yii-runner-console: ^2.2
- yiisoft/yii-runner-http: ^3.2
Requires (Dev)
- codeception/c3: ^2.9
- codeception/codeception: ^5.3.2
- codeception/lib-innerbrowser: ^4.0.6
- codeception/module-asserts: ^3.2
- codeception/module-cli: ^2.0.1
- codeception/module-db: ^3.2.2
- codeception/module-phpbrowser: ^3.0.2
- codeception/module-rest: ^3.4.1
- friendsofphp/php-cs-fixer: ^3.88.2
- phpunit/phpunit: ^11.5.42
- rector/rector: ^2.1.7
- roave/infection-static-analysis-plugin: ^1.39
- shipmonk/composer-dependency-analyser: ^1.8.3
- vimeo/psalm: ^6.13.1
This package is auto-updated.
Last update: 2025-10-02 13:28:54 UTC
README
Yii API application
An application template for a new API project
The package is an API application template. If you need console only or classic web please start with corresponding templates:
Requirements
- PHP 8.2 or higher.
Installation
Local installation
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
Create a project:
composer create-project yiisoft/app-api myproject
cd myproject
To run the app:
APP_ENV=dev ./yii serve
Now you should be able to access the application through the URL printed to console.
Usually it is http://localhost:8080
.
Installation with Docker
Warning
Docker compose version 2.24 or above is required.
Fork the repository, clone it, then:
cd myproject
make composer update
To run the app:
make up
To stop the app:
make down
The application is available at https://localhost
.
Other make commands are available in the Makefile
and can be listed with:
make help
Directory structure
The application template has the following structure:
config/ Configuration files.
common/ Common configuration and DI definitions.
console/ Console-specific configuration.
environments/ Environment-specific configuration (dev/test/prod).
web/ Web-specific configuration.
docker/ Docker-specific files.
public/ Files publically accessible from the Internet.
index.php Entry script.
runtime/ Files generated during runtime.
src/ Application source code.
Api/ API action handlers and API-specific code.
Shared/ Shared API components (middleware, presenters, factories).
Console/ Console commands.
Shared/ Code shared between API and console applications.
tests/ A set of Codeception tests for the application.
Api/ API endpoints tests.
Console/ Console command tests.
Functional/ Functional tests.
Unit/ Unit tests.
vendor/ Installed Composer packages.
Makefile Config for make command.
yii Console application entry point.
Testing
The template comes with ready to use Codeception configuration. To execute tests, in local installation run:
./vendor/bin/codecept build APP_ENV=test ./yii serve > ./runtime/yii.log 2>&1 & ./vendor/bin/codecept run
For Docker:
make codecept build make codecept run
Static analysis
The code is statically analyzed with Psalm. To run static analysis:
./vendor/bin/psalm
or, using Docker:
make psalm
Support
If you need help or have a question, check out Yii Community Resources.
License
The Yii3 API template is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.