Skip to content

Commit 292676c

Browse files
committed
updated installation
Signed-off-by: bidi <bidi@apidemia.com>
1 parent 4bc50b1 commit 292676c

4 files changed

Lines changed: 124 additions & 93 deletions

File tree

docs/book/v7/installation/composer.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ composer install
1616

1717
You should see this text below, along with a long list of packages to be installed instead of the `[...]`.
1818
In this example there are 164 packages, though the number can change in future updates.
19-
You will find the packages in the `vendor` folder.
19+
You will find the packages in the newly-created `vendor` folder.
2020

2121
```shell
2222
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
@@ -42,8 +42,8 @@ Please select which config file you wish to inject 'Laminas\Diactoros\ConfigProv
4242
4343
Type `0` to select `[0] Do not inject`.
4444
45-
> We choose `0` because Dotkernel includes its own ConfigProvider, which already contains the prompted configurations.
46-
> If you choose `[1] config/config.php`, an extra `ConfigProvider` will be injected.
45+
> If you choose `1`, an extra `ConfigProvider` will be injected, which may return an error for packages you add in the future.
46+
> Choosing `0` prevents duplicate ConfigProvider registrations, as Dotkernel already includes its own.
4747
4848
The next question is:
4949
@@ -53,20 +53,23 @@ Type `y` here, and hit `enter` to complete this stage.
5353
5454
## Development mode
5555
56-
If you're installing the project for development, make sure you have development mode enabled by running:
56+
Normally, a new project starts in development mode to prevent caching certain files in the `data/cache` folder.
57+
Enable development mode by running:
5758
5859
```shell
5960
composer development-enable
6061
```
6162
62-
You can disable the development mode by running:
63+
If you ever need to disable the development mode, run:
6364
6465
```shell
6566
composer development-disable
6667
```
6768
68-
You can check if you have development mode enabled by running:
69+
This command displays the development mode status:
6970
7071
```shell
7172
composer development-status
7273
```
74+
75+
You should see the message `Development mode is ENABLED` or `Development mode is DISABLED`.
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# Configuration Files
22

3-
> The installation script should have already created the files mentioned on this page.
4-
> We mention them explicitly because you will need to visit them to fully configure your development environment.
3+
The installation script from `composer.json` (under the key 'post-update-cmd') should have already created the files mentioned on this page.
4+
We mention them explicitly because you will need to visit them to fully configure your development environment.
55

66
## Prepare config files
77

8-
* duplicate `config/autoload/cors.local.php.dist` as `config/autoload/cors.local.php`
8+
The installation script will duplicate the following files:
9+
10+
* `config/autoload/cors.local.php.dist` as `config/autoload/cors.local.php`.
911

1012
> If your API is consumed by another application, make sure to configure the `allowed_origins` variable.
13+
> Normally, the other configuration items in `cors.local.php` should be left as-is.
14+
> If you need to tweak them, visit the [CORS tutorial](https://docs.dotkernel.org/api-documentation/v7/tutorials/cors/).
15+
16+
* `config/autoload/local.php.dist` as `config/autoload/local.php`.
1117

12-
* duplicate `config/autoload/local.php.dist` as `config/autoload/local.php`
18+
> `local.php` is the main configuration file for your application.
19+
> It contains the database connection parameters, the API key, and other configuration items.
1320
14-
* duplicate `config/autoload/mail.local.php.dist` as `config/autoload/mail.local.php`
21+
* `config/autoload/mail.local.php` from the `dot-mail` package installed in the `vendor` folder.
1522

16-
> If your API sends emails, make sure to fill in SMTP connection params
23+
> If your API sends emails, you also need to configure the `mail` key.
24+
> Most often, you will be using either `Sendmail` or `SMTP` to send emails.
25+
> If you opt for `SMTP`, ake sure to configure the SMTP connection parameters under the `smtp_options` key.
1726
18-
* **optional**: to run/create tests, duplicate `config/autoload/local.test.php.dist` as `config/autoload/local.test.php`
27+
* `config/autoload/local.test.php.dist` as `config/autoload/local.test.php` to run and create tests.
1928

2029
> This creates a new in-memory database that your tests will run on.

docs/book/v7/installation/doctrine-orm.md

Lines changed: 81 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
This step saves the database connection credentials in an API configuration file.
44
We do not cover the creation steps of the database itself.
55

6+
In this step you will:
7+
8+
- Create a database.
9+
- Create and run a database migration that creates the main tables.
10+
- Execute fixtures which populate the database with initial data.
11+
612
## Setup database
713

814
Create a new **MariaDB**/**PostgreSQL** database and set its collation to `utf8mb4_general_ci`.
@@ -35,87 +41,19 @@ $databases = [
3541
];
3642
```
3743

38-
`my_database`, `my_user`, `my_password` are provided only as an example.
39-
40-
> You can add more database connections to this array.
41-
> Only one active connection is allowed at a time.
42-
> By default, the application uses the 'mariadb' connection.
43-
> You can switch to another connection by activating it under `doctrine` -> `connection` -> `orm_default` -> `params`.
44-
45-
### Creating migrations
46-
47-
Create a database migration by executing the following command:
48-
49-
```shell
50-
php ./vendor/bin/doctrine-migrations diff
51-
```
52-
53-
The new migration file will be placed in `src/Core/src/App/src/Migration/`.
54-
55-
### Running migrations
56-
57-
Run the database migrations by executing the following command:
58-
59-
```shell
60-
php ./vendor/bin/doctrine-migrations migrate
61-
```
62-
63-
> If you have already run the migrations, you may get the below message:
64-
65-
```text
66-
WARNING! You have x previously executed migrations in the database that are not registered migrations.
67-
{migration list}
68-
Are you sure you wish to continue? (y/n)
69-
```
70-
71-
> In this case, you should double-check to make sure the new migrations are ok to run.
72-
73-
When using an empty database, you will get this confirmation message:
74-
75-
```text
76-
WARNING! You are about to execute a migration in database "<your_database_name>" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no)
77-
```
78-
79-
Hit `Enter` to confirm the operation.
80-
This will run all the migrations in chronological order.
81-
Each migration will be logged in the `migrations` table to prevent running the same migration more than once, which is often not desirable.
82-
83-
If everything ran correctly, you will get this confirmation.
84-
85-
```text
86-
[OK] Successfully migrated to version: Core\App\Migration\VersionYYYYMMDDHHMMSS
87-
```
88-
89-
### Executing fixtures
90-
91-
**Fixtures are used to seed the database with initial values and should be executed after migrating the database.**
92-
93-
To list all the fixtures, run:
94-
95-
```shell
96-
php ./bin/doctrine fixtures:list
97-
```
98-
99-
This will output all the fixtures in the order of execution.
100-
101-
To execute all fixtures, run:
102-
103-
```shell
104-
php ./bin/doctrine fixtures:execute
105-
```
106-
107-
To execute a specific fixture, run:
44+
> The database `dotkernel` is provided as an example, but you can use any name you like.
45+
> Make sure to use the same database name when you create the database in the next step.
10846
109-
```shell
110-
php ./bin/doctrine fixtures:execute --class=FixtureClassName
111-
```
47+
> If needed, you can add more database connections to this array.
48+
> Only **one active database connection** is allowed at a time.
11249
113-
More details on how fixtures work can be found on [dot-data-fixtures documentation](https://github.com/dotkernel/dot-data-fixtures#creating-fixtures)
50+
> By default, the application uses the 'mariadb' connection.
51+
> You can switch to another connection by updating `doctrine` -> `connection` -> `orm_default` -> `params`.
11452
11553
### Prefixing table names
11654

117-
The database configuration array contains the key called `table_prefix`.
118-
By default, it is an empty string, which means that all the tables will use the names specified in their respective entities.
55+
The database configuration array contains an optional key called `table_prefix`.
56+
By default, it is an empty string, which means that all the tables will use the names specified in their respective entities, like below.
11957

12058
```text
12159
├─ admin
@@ -140,6 +78,7 @@ By default, it is an empty string, which means that all the tables will use the
14078
```
14179

14280
By adding a prefix, for example `dot_`, all the table names will have the prefix appended to the table names specified in the entities.
81+
This feature helps organize databases and prevent naming conflicts if you plan on installing multiple applications in a single database.
14382

14483
```text
14584
├─ dot_admin
@@ -166,3 +105,69 @@ By adding a prefix, for example `dot_`, all the table names will have the prefix
166105
> The configured prefix is prepended as is, no intermediary character will be added.
167106
168107
> `doctrine_migration_versions` is an exception and will remain unchanged, since it's a special table handled only by Doctrine Migrations.
108+
109+
### Creating migrations
110+
111+
Create a database migration by executing the following command:
112+
113+
```shell
114+
php ./vendor/bin/doctrine-migrations diff
115+
```
116+
117+
You can expect a message like this:
118+
119+
```shell
120+
Generated new migration class to "src/Core/src/App/src/Migration/Version20260327154303.php"
121+
122+
To run just this migration for testing purposes, you can use migrations:execute --up "Core\\App\\Migration\\Version20260327154303"
123+
124+
To revert the migration you can use migrations:execute --down "Core\\App\\Migration\\Version20260327154303"
125+
```
126+
127+
### Running migrations
128+
129+
Run the database migrations by executing the following command:
130+
131+
```shell
132+
php ./vendor/bin/doctrine-migrations migrate
133+
```
134+
135+
> If you have already run the migrations, you may get the below message:
136+
137+
```text
138+
WARNING! You have x previously executed migrations in the database that are not registered migrations.
139+
{migration list}
140+
Are you sure you wish to continue? (y/n)
141+
```
142+
143+
> In this case, you should double-check to make sure the new migrations are ok to run.
144+
145+
When using an empty database, you will get this confirmation message:
146+
147+
```text
148+
WARNING! You are about to execute a migration in database "<your_database_name>" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no)
149+
```
150+
151+
Hit `Enter` to confirm the operation.
152+
This will run all the migrations in chronological order.
153+
Each migration will be logged in the `migrations` table to prevent running the same migration more than once, which is often not desirable.
154+
155+
If everything ran correctly, you will get this confirmation.
156+
157+
```text
158+
[OK] Successfully migrated to version: Core\App\Migration\VersionYYYYMMDDHHMMSS
159+
```
160+
161+
> The version number `YYYYMMDDHHMMSS` is the timestamp of the migration.
162+
163+
### Executing fixtures
164+
165+
**Fixtures are used to seed the database with initial values and should be executed after migrating the database.**
166+
167+
To execute fixtures, run:
168+
169+
```shell
170+
php ./bin/doctrine fixtures:execute
171+
```
172+
173+
More details on how fixtures work can be found on [dot-data-fixtures documentation](https://github.com/dotkernel/dot-data-fixtures#usage)

docs/book/v7/installation/getting-started.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
## Recommended development environment
44

5-
> If you are using Windows as an OS on your machine, you can use WSL2 as a development environment.
6-
> Read more here: [PHP-Mariadb-on-WLS2](https://www.dotkernel.com/php-development/almalinux-9-in-wsl2-install-php-apache-mariadb-composer-phpmyadmin/)
5+
> If you are using the Microsoft Windows Operating System on your machine, you can use WSL2 as a development environment.
6+
> Read more about [PHP Mariadb on WLS2](https://www.dotkernel.com/php-development/almalinux-9-in-wsl2-install-php-apache-mariadb-composer-phpmyadmin/).
77
8-
Using your terminal, navigate inside the directory you want to download the project files into.
9-
Make sure that the directory is empty before proceeding to the download process. Once there, run the following command:
8+
Using your terminal, navigate inside the directory where you want to download the project files.
9+
10+
> Make sure that the directory is empty before running the command below.
11+
12+
Run this command to clone the project files.
1013

1114
```shell
1215
git clone https://github.com/dotkernel/api.git .
1316
```
17+
18+
To prevent future permission errors, certain folders must have their permissions set to 777.
19+
This way they assign everyone (owner, group, and other users) permissions to read, write, and execute.
20+
21+
```shell
22+
chmod -R 777 data
23+
chmod -R 777 public/uploads
24+
chmod -R 777 log
25+
```
26+
27+
> The `-R` parameter is used to recursively apply the permissions to all subdirectories and files.

0 commit comments

Comments
 (0)