Skip to content

Commit 1469fe5

Browse files
committed
update docs contents
1 parent 22f2ece commit 1469fe5

File tree

19 files changed

+225
-154
lines changed

19 files changed

+225
-154
lines changed

src/app/console/output/output.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ <h3>Console Color</h3>
120120
<li><code>DevNet\System\IO\Console::$ForegroundColor</code></li>
121121
<li><code>DevNet\System\IO\Console::$BackgroundColor</code></li>
122122
</ul>
123+
<p>
124+
To reset the colors back to default, use the static method <code>DevNet\System\IO\Console::resetColor()</code>
125+
</p>
123126
<p>
124127
The following code example prints all the foreground and background colors, then reset the console colors to the defaults at the end.
125128
</p>

src/app/console/start/start.component.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ <h3>Create Console Project</h3>
1515
To create a DevNet console project, enter the command below in the Terminal, where the argument <code>project-name</code> is any name you give to your project:
1616
</p>
1717
<pre><code class="language-shell">devnet new console --output project-name</code></pre>
18+
<p>
19+
Or, using the composer command-line:
20+
</p>
21+
<pre><code class="language-shell">composer create-project devnet/console-template project-name</code></pre>
1822
<br>
1923
<h4>Project Structure</h4>
2024
<p>
21-
DevNet CLI will create a simple console template with the following project structure:
25+
The DevNet console project has the following folder structure:
2226
</p>
2327
<pre><code class="language-shell">console-project/
2428
├── bin/
@@ -54,7 +58,11 @@ <h3>Run The Application</h3>
5458
</p>
5559
<pre><code class="language-shell">devnet run</code></pre>
5660
<p>
57-
The program displays a <samp>"Hello World!"</samp> message in the console and ends.
61+
Or, launch the application bin file directly:
62+
</p>
63+
<pre><code class="language-shell">./bin/run</code></pre>
64+
<p>
65+
The program will display a <samp>"Hello World!"</samp> message in the console.
5866
</p>
5967
<pre><code class="language-shell">Hello World!</code></pre>
6068
</article>

src/app/core/asynchronous/asynchronous.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ <h3>Async/Await Pattern</h3>
152152
</a>
153153
</li>
154154
<li class="nav-page-item">
155-
<a class="nav-page-link" routerLink="/docs/core/delegate">
155+
<a class="nav-page-link" routerLink="/docs/core/delegates">
156156
Next <i class="chevron right"></i>
157157
</a>
158158
</li>

src/app/docs/docs.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="d-flex flex-column justify-content-center text-center" style="height: 280px; background-color: rebeccapurple;">
1+
<div class="d-flex flex-column justify-content-center text-center p-3" style="min-height: 280px; background-color: rebeccapurple;">
22
<h1 class="text-white display-4 mx-auto">DevNet Documentation</h1>
33
<p class="lead text-white w-75 mx-auto">Learn how to use DevNet Framework for rapid application development on any
44
platform, using PHP with a new experience to the next level.</p>

src/app/entity/migrations/migrations.component.html

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,51 @@ <h4>Creating the database Schema</h4>
7171
&lcub;
7272
public function up(MigrationBuilder $builder): void
7373
&lcub;
74-
$builder->createTable('User', function ($table) &lcub;;
74+
$builder->createTable('User', function ($table) &lcub;
7575
$table->column('Id', 'integer')->identity(); // auto-increment
76+
$table->column('Fullname', 'string', 45)->nullable(false);
7677
$table->column('Username', 'string', 45)->nullable(false);
7778
$table->column('Password', 'string', 60)->nullable(false);
79+
$table->column('Role', 'string', 45)->default('User');
7880
$table->primaryKey('Id');
7981
$table->uniqueConstraint('Username');
8082
});
8183

82-
$builder->createTable('Role', function ($table) &lcub;;
84+
$builder->createTable('Post', function ($table) &lcub;
85+
$table->column('Id', 'integer')->identity();
86+
$table->column('UserId', 'integer');
87+
$table->column('Title', 'string', 60)->nullable(false);
88+
$table->column('Content', 'text');
89+
$table->column('Date', 'date');
90+
$table->primaryKey('Id');
91+
$table->foreignKey('UserId')->references('User', 'Id')->onDelete('cascade');
92+
});
93+
94+
$builder->createTable('Category', function ($table) &lcub;
8395
$table->column('Id', 'integer')->identity();
8496
$table->column('Name', 'string', 45)->nullable(false);
85-
$table->column('Description', 'string')->default('role description');
97+
$table->column('Description', 'string', 255)->nullable();
8698
$table->primaryKey('Id');
99+
$table->uniqueConstraint('Name');
87100
});
88101

89-
$builder->createTable('UserRole', function ($table) &lcub;;
90-
$table->column('UserId', 'integer');
91-
$table->column('RoleId', 'integer');
92-
$table->primaryKey('UserId', 'RoleId');
93-
$table->foreignKey('UserId')->references('User', 'Id')->onDelete('cascade');
94-
$table->foreignKey('RoleId')->references('Role', 'Id')->onDelete('cascade');
102+
$builder->createTable('PostCategory', function ($table) &lcub;
103+
$table->column('PostId', 'integer');
104+
$table->column('CategoryId', 'integer');
105+
$table->primaryKey('PostId', 'CategoryId');
106+
$table->foreignKey('PostId')->references('Post', 'Id')->onDelete('cascade');
107+
$table->foreignKey('CategoryId')->references('Category', 'Id')->onDelete('cascade');
95108
});
96109
}
97110

98111
public function down(MigrationBuilder $builder): void
99112
&lcub;
100113
// if the constraint ON DELETE is configured as "strict" and which is the default configuration,
101114
// the child table must be dropped before the parent table, otherwise will throw an error.
102-
$builder->dropTable('UserRole');
115+
$builder->dropTable('PostCategory');
116+
$builder->dropTable('Category');
117+
$builder->dropTable('Post');
103118
$builder->dropTable('User');
104-
$builder->dropTable('Role');
105119
}
106120
}
107121
</code></pre>
@@ -122,17 +136,16 @@ <h4>Updating the database schema</h4>
122136
public function up(MigrationBuilder $builder): void
123137
&lcub;
124138
$builder->alterTable('User', function ($table) &lcub;
125-
$table->addColumn('Fullname', 'string', 60);
126139
$table->addColumn('Email', 'string', 45);
127140
$table->addColumn('Phone', 'string', 15);
128141
$table->addColumn('Location', 'string', 45);
129142
});
130143

131-
$builder->alterTable('Role', function ($table) &lcub;
144+
$builder->alterTable('Category', function ($table) &lcub;
132145
$table->renameColumn('Description', 'Definition');
133146
});
134147

135-
$builder->renameTable('UserRole', 'Assignment');
148+
$builder->renameTable('PostCategory', 'Classification');
136149
}
137150

138151
public function down(MigrationBuilder $builder): void
@@ -144,11 +157,11 @@ <h4>Updating the database schema</h4>
144157
$table->removeColumn('Location');
145158
});
146159

147-
$builder->alterTable('Role', function ($table) &lcub;
160+
$builder->alterTable('Category', function ($table) &lcub;
148161
$table->renameColumn('Definition', 'Description');
149162
});
150163

151-
$builder->renameTable('Assignment', 'UserRole');
164+
$builder->renameTable('Classification', 'PostCategory');
152165
}
153166
}
154167
</code></pre>
@@ -168,19 +181,19 @@ <h4>Seeding the database</h4>
168181
&lcub;
169182
public function up(MigrationBuilder $builder): void
170183
&lcub;
171-
$roles = ['admin', 'moderator', 'editor', 'reader'];
184+
$roles = ['uncategorized', 'featured', 'events', 'news'];
172185
foreach ($roles as $id => $name) &lcub;
173-
$builder->insertData('Role', [
174-
'Id' => $id,
186+
$builder->insertData('Category', [
187+
'Id' => ++$id,
175188
'Name' => $name
176189
]);
177190
}
178191
}
179192

180193
public function down(MigrationBuilder $builder): void
181194
&lcub;
182-
for ($i=1; $i <= 4; $i++) &lcub;
183-
$builder->deleteData('Role', ['Id' => $i]);
195+
for ($i = 1; $i <= 4; $i++) &lcub;
196+
$builder->deleteData('Category', ['Id' => $i]);
184197
}
185198
}
186199
}

src/app/entity/relationships/relationships.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ <h1>Relationships</h1>
1111
A relationship describes how entities are associated with each other, represented by a referential constraint that defines which entity is the principal or dependent role in the relationship, and there are many kinds of entity relationships, such as one-to-one, one-to-many, many-to-one, and many-to-many.
1212
</p>
1313
<ul>
14-
<li class="mb-2"><b>Dependent entity:</b> sometimes called the 'child,' is the entity that contains the foreign key, which is a reference to the primary key of the principal entity.</li>
15-
<li class="mb-2"><b>Principal entity:</b> sometimes called the 'parent,' is the entity that contains the primary key, which is referenced as a foreign key in the dependent entity.</li>
14+
<li class="mb-2"><b>Dependent entity:</b> sometimes called the "child" is the entity that contains the foreign key, which is a reference to the primary key of the principal entity.</li>
15+
<li class="mb-2"><b>Principal entity:</b> sometimes called the "parent" is the entity that contains the primary key, which is referenced as a foreign key in the dependent entity.</li>
1616
</ul>
1717
<h3>Navigation property:</h3>
1818
<p>
@@ -31,7 +31,7 @@ <h3>Navigation property:</h3>
3131

3232
use DevNet\Entity\Annotations\ForeignKey;
3333
use DevNet\System\Collections\ICollection;
34-
use DevNet\System\Generic;
34+
use DevNet\System\Type;
3535
use DateTime;
3636

3737
class Post
@@ -45,7 +45,7 @@ <h3>Navigation property:</h3>
4545
#[ForeignKey('UserId')]
4646
public User $User;
4747

48-
#[Generic(Classification::class)]
48+
#[Type(ICollection::class, [Classification::class])]
4949
public ICollection $Classifications;
5050
}
5151
</code></pre>
@@ -85,7 +85,7 @@ <h3>One to Many</h3>
8585

8686
$blog = new BlogContext();
8787
$user = $blog->Users->find($id);
88-
// iterating through the posts that are related to the selected user.
88+
// Iterating through the posts that are related to the selected user.
8989
foreach($user->Posts as $post) &lcub;
9090
$post->Title;
9191
}
@@ -187,7 +187,7 @@ <h3>Many to Many</h3>
187187

188188
$blog = new BlogContext();
189189
$category = $blog->Categories->find($id);
190-
// Iterate the related entities through the junction entity.
190+
// Iterates the related entities through the junction entity.
191191
foreach($category->Classifications as $classification) &lcub;
192192
$classification->Post->Title;
193193
}

src/app/entity/save/save.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ <h3>Multiple Operations</h3>
7070

7171
$blog = new BlogContext();
7272

73-
// add new post
73+
// Adds new post
7474
$post = new Post();
7575
$post->Title = "Post Title";
7676
$post->Content = "Some content...";
7777
$post->Date = new DateTime("now");
7878
$blog->Post->add($post);
7979

80-
// delete post with id = 2
80+
// Deletes post with id = 2
8181
$post = $blog->Post->find(2);
8282
$blog->Post->remove($post);
8383

84-
// update post with id = 1
84+
// Updates post with id = 1
8585
$post = $blog->Post->find(1);
8686
$post->Content = "Updated content";
8787

88-
// persist all the operations
88+
// Persists all the operations
8989
$blog->Post->save();
9090
</code></pre>
9191
</article>

src/app/entity/start/start.component.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h4>Entity Type</h4>
7676
</li>
7777
</ul>
7878
<p>
79-
The following code example is the entity class <code>Application\Models\Post</code> used in the previous context, and it represents the <b>Post</b> table in the database where the properties represent the columns of that table.
79+
The following code example is the entity class <code>Application\Models\Post</code> used in the previous context, and it represents the <b>"Post"</b> table in the database where the properties represent the columns of that table.
8080
</p>
8181
<pre><code class="language-php">&lt;?php
8282

@@ -139,50 +139,50 @@ <h3>Connecting to the Database</h3>
139139

140140
use Application\Models\BlogContext;
141141
use DevNet\Entity\EntityOptions;
142-
use DevNet\Entity\MySql\MySqlDataProvider;
142+
use DevNet\Entity\Sqlite\SqliteDataProvider;
143143

144144
$options = new EntityOptions();
145-
$options->ProviderType = MySqlDataProvider::class;
146-
$options->ConnectionString = "//username:[email protected]/blog";
145+
$options->ProviderType = SqliteDataProvider::class;
146+
$options->ConnectionString = "/path/to/database.db3";
147147

148148
$blog = new BlogContext($options);
149149
$posts = $blog->Posts;
150150
</code></pre>
151151
<br>
152-
<h4>Data Providers</h4>
152+
<h4>Database Providers</h4>
153153
<p>
154-
The following table shows a list of database providers that Entity ORM supports with the corresponding connection string to each one.
154+
The following table shows a list of database providers that are supported by Entity ORM.
155155
</p>
156156
<table class="table">
157157
<thead>
158158
<tr>
159-
<th scope="col">Driver</th>
160-
<th scope="col">Data Provider</th>
161-
<th scope="col">Connection String</th>
159+
<th scope="col">Database Provider</th>
160+
<th scope="col">Database Engine</th>
162161
</tr>
163162
</thead>
164163
<tbody>
165164
<tr>
166-
<td>MySql</td>
167165
<td><code>DevNet\Entity\MySql\MySqlDataProvider</code></td>
168-
<td><samp>"//username:[email protected]:3306/database"</samp></td>
166+
<td>MySql</td>
169167
</tr>
170168
<tr>
171-
<td>PostgreSql</td>
172169
<td><code>DevNet\Entity\PgSql\PgSqlDataProvider</code></td>
173-
<td><samp>"//username:[email protected]:5432/database"</samp></td>
170+
<td>PostgreSql</td>
174171
</tr>
175172
<tr>
176-
<td>SQLite</td>
177173
<td><code>DevNet\Entity\Sqlite\SqliteDataProvider</code></td>
178-
<td><samp>"//path/to/database"</samp></td>
174+
<td>SQLite</td>
179175
</tr>
180176
</tbody>
181177
</table>
182178
<h4>Connection String</h4>
183179
<p>
184-
The connection string used by the database providers follows the following url format:<br>
185-
<code>"//[username]:[password]@[host]:[port]/[database]?[option=value]"</code>
180+
The client-server database providers like "MySql" and "PostgreSql" use the following connection string format:<br>
181+
<code>"host=hostname;port=port;database=dbname;user=username;password=password"</code>
182+
</p>
183+
<p>
184+
The serverless database providers like "SQLite" use the following connection string format:<br>
185+
<code>"/path/to/database.db3"</code> or <code>":memory:"</code>
186186
</p>
187187
<br>
188188
<h3>Registering the EntityContext</h3>
@@ -205,7 +205,7 @@ <h3>Registering the EntityContext</h3>
205205
$builder = WebHost::createDefaultBuilder($args);
206206
$configuration = $builder->Configuration;
207207
$builder->register(function ($services) use ($configuration) &lcub; //;
208-
// adding EntityContext
208+
// Adding EntityContext
209209
$services->addEntityContext(BlogContext::class,
210210
function ($options) &lcub;
211211
$options->ProviderType = $configuration->getValue('Database:ProviderType');
@@ -221,8 +221,8 @@ <h3>Registering the EntityContext</h3>
221221
In the <samp>"settings.json"</samp> file, you need to set the database configuration, like in the following example:
222222
</p>
223223
<pre><code class="language-json">"Database": &lcub;
224-
"ProviderType": "DevNet\\Entity\\MySql\\MySqlDataProvider",
225-
"ConnectionString": "//username:password@127.0.0.1/blog"
224+
"ProviderType": "DevNet\\Entity\\PgSql\\PgSqlDataProvider",
225+
"ConnectionString": "host=localhost;database=dbname;user=username;password=password"
226226
}
227227
</code></pre>
228228
<p>

src/app/security/authentication/authentication.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h3>Configuration</h3>
7070
// Adding the authentication middleware before the endpoint middleware.
7171
$app->useAuthentication();
7272
$app->useEndpoint(function ($routes) &lcub;
73-
// routes
73+
// Routes
7474
});
7575
});
7676
}
@@ -109,12 +109,12 @@ <h3>Cookie-based Authentication</h3>
109109
return $context->Response->setStatusCode(401);
110110
}
111111

112-
$user = new ClaimsIdentity(AuthenticationScheme::CookieSession);
113-
$user->addClaim(new Claim('Username' , $form->getValue('username')));
114-
$user->addClaim(new Claim('Role', $user->Role));
112+
$identity = new ClaimsIdentity(AuthenticationScheme::CookieSession);
113+
$identity->addClaim(new Claim('Username' , $form->getValue('username')));
114+
$identity->addClaim(new Claim('Role', $user->Role));
115115

116116
$authentication = $context->Services->getService(IAuthentication::class);
117-
$authentication->signIn($user, $form->getValue('remember'));
117+
$authentication->signIn($identity, $form->getValue('remember'));
118118
}
119119

120120
return $context->Response->redirect('/account');

src/app/security/overview/overview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h3>Requirement</h3>
2727
<nav class="no-print" aria-label="Page navigation">
2828
<ul class="nav-page">
2929
<li class="nav-page-item">
30-
<a class="nav-page-link" routerLink="/docs/web/exception">
30+
<a class="nav-page-link" routerLink="/docs/web/dependency">
3131
<i class="chevron left"></i> Previous
3232
</a>
3333
</li>

0 commit comments

Comments
 (0)