Skip to content
Draft
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Application environment (dev, test, prod)
APP_ENV=dev

# Enable debug mode in development
APP_DEBUG=true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ Thumbs.db
# composer vendor dir
/vendor

# environment configuration
.env

# Codeception C3
c3.php
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,23 @@ composer create-project yiisoft/app-api myproject
cd myproject
```

Copy the `.env.example` file to `.env`:

```shell
cp .env.example .env
```

The `.env` file contains environment-specific configuration. By default, it sets `APP_ENV=dev` for development.
You can customize it as needed.

To run the app:

```shell
./yii serve
```

Alternatively, you can still use the `APP_ENV` environment variable directly:

```shell
APP_ENV=dev ./yii serve
```
Expand Down Expand Up @@ -111,10 +126,28 @@ tests/ A set of Codeception tests for the application.
Functional/ Functional tests.
Unit/ Unit tests.
vendor/ Installed Composer packages.
.env.example Example environment configuration (copy to .env for local dev).
Makefile Config for make command.
yii Console application entry point.
```

## Environment Configuration

For local development (non-Docker), you can use a `.env` file to configure the environment:

1. Copy `.env.example` to `.env`:
```shell
cp .env.example .env
```

2. The `.env` file is automatically loaded and sets environment variables like `APP_ENV`.

3. The `.env` file is excluded from git, so each environment can have its own configuration.

4. If no `.env` file exists and no `APP_ENV` is set, the application defaults to `prod` environment.

For Docker environments, use the `.env` files in the `docker/` directory as before.

## Testing

The template comes with ready to use [Codeception](https://codeception.com/) configuration.
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"psr/http-server-middleware": "^1.0.2",
"psr/log": "^3.0.2",
"symfony/console": "^7.3.4",
"vlucas/phpdotenv": "^5.6",
"yiisoft/aliases": "^3.1",
"yiisoft/config": "^1.6",
"yiisoft/data": "^1.0.1",
Expand Down
Loading
Loading