You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/v7/installation/composer.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ composer install
16
16
17
17
You should see this text below, along with a long list of packages to be installed instead of the `[...]`.
18
18
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.
20
20
21
21
```shell
22
22
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
42
42
43
43
Type `0` to select`[0] Do not inject`.
44
44
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 forpackages you addin the future.
46
+
>Choosing `0` prevents duplicate ConfigProvider registrations, as Dotkernel already includes its own.
47
47
48
48
The next question is:
49
49
@@ -53,20 +53,23 @@ Type `y` here, and hit `enter` to complete this stage.
53
53
54
54
## Development mode
55
55
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:
57
58
58
59
```shell
59
60
composer development-enable
60
61
```
61
62
62
-
You can disable the development mode by running:
63
+
If you ever need to disable the development mode, run:
63
64
64
65
```shell
65
66
composer development-disable
66
67
```
67
68
68
-
You can check if you have development mode enabled by running:
69
+
This command displays the development mode status:
69
70
70
71
```shell
71
72
composer development-status
72
73
```
74
+
75
+
You should see the message `Development mode is ENABLED` or `Development mode is DISABLED`.
Copy file name to clipboardExpand all lines: docs/book/v7/installation/doctrine-orm.md
+81-76Lines changed: 81 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,12 @@
3
3
This step saves the database connection credentials in an API configuration file.
4
4
We do not cover the creation steps of the database itself.
5
5
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
+
6
12
## Setup database
7
13
8
14
Create a new **MariaDB**/**PostgreSQL** database and set its collation to `utf8mb4_general_ci`.
@@ -35,87 +41,19 @@ $databases = [
35
41
];
36
42
```
37
43
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.
> If needed, you can add more database connections to this array.
48
+
> Only **one active database connection** is allowed at a time.
112
49
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`.
114
52
115
53
### Prefixing table names
116
54
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.
119
57
120
58
```text
121
59
├─ admin
@@ -140,6 +78,7 @@ By default, it is an empty string, which means that all the tables will use the
140
78
```
141
79
142
80
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.
143
82
144
83
```text
145
84
├─ dot_admin
@@ -166,3 +105,69 @@ By adding a prefix, for example `dot_`, all the table names will have the prefix
166
105
> The configured prefix is prepended as is, no intermediary character will be added.
167
106
168
107
> `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)
0 commit comments