Skip to content

Commit 3eef8c7

Browse files
committed
update docs content
1 parent 0113da2 commit 3eef8c7

22 files changed

+211
-171
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,22 @@ <h3>Console Color</h3>
134134
&lcub;
135135
public static function main(array $args = [])
136136
&lcub;
137-
Console::writeLine("The foreground Colors:");
137+
Console::$ForegroundColor = ConsoleColor::Black;
138+
Console::$BackgroundColor = ConsoleColor::White;
139+
Console::writeLine("List of the foreground Colors:");
140+
Console::resetColor();
141+
138142
foreach (ConsoleColor::cases() as $color) &lcub;
139143
Console::$ForegroundColor = $color;
140144
Console::writeLine("The foreground color &lcub;0} is &lcub;1}", $color->value, $color->name);
141145
}
142146

143-
Console::resetColor();
144147
Console::writeLine();
148+
Console::$ForegroundColor = ConsoleColor::Black;
149+
Console::$BackgroundColor = ConsoleColor::White;
150+
Console::writeLine("List of the background colors:");
151+
Console::resetColor();
145152

146-
Console::writeLine("The background Colors:");
147153
foreach (ConsoleColor::cases() as $color) &lcub;
148154
Console::$BackgroundColor = $color;
149155
Console::writeLine("The background color &lcub;0} is &lcub;1}", $color->value, $color->name);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ <h4>Project Structure</h4>
2525
| ├── apphost
2626
| ├── run.bat
2727
| └── run
28+
├── src/
29+
| └── Program.php
2830
├── vendor/
29-
├── devnet.proj
30-
└── Program.php</code></pre>
31+
└── devnet.proj</code></pre>
3132
<br>
3233
<h4>Entry Point</h4>
3334
<p>

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ <h3>Async/Await Pattern</h3>
9191
The async/await pattern is a feature related to the coroutine concept, where the async function can use the await operator to suspend the asynchronous operation until that operation completes and then returns a result. This enables asynchronous non-blocking functions to be structured like normal synchronous functions in the enclosing scope without blocking the main thread during the execution of the async function, which also returns a task object that represents an asynchronous operation and provides a result when the task completes successfully.
9292
</p>
9393
<pre><code class="language-php">&lt;?php
94-
94+
95+
use DevNet\System\IO\FileAccess;
96+
use DevNet\System\IO\FileMode;
9597
use DevNet\System\IO\FileStream;
9698

9799
use function DevNet\System\async;
98100
use function DevNet\System\await;
99101

100102
$readJsonAsync = async(function($path): string &lcub;
101-
$file = new FileStream($path, 'r');
103+
$file = new FileStream($path, FileMode::Open, FileAccess::Read);
102104
// Await for the async reading to complete without blocking the outside scope.
103105
$json = await($file->readAsync($file->Length));
104106
$data = json_decode($json);
@@ -115,6 +117,8 @@ <h3>Async/Await Pattern</h3>
115117
</p>
116118
<pre><code class="language-php">&lt;?php
117119

120+
use DevNet\System\IO\FileAccess;
121+
use DevNet\System\IO\FileMode;
118122
use DevNet\System\IO\FileStream;
119123
use DevNet\System\MethodTrait;
120124

@@ -126,7 +130,7 @@ <h3>Async/Await Pattern</h3>
126130

127131
public async_readJsonAsync(function($path): string
128132
&lcub;
129-
$file = new FileStream($path, 'r');
133+
$file = new FileStream($path, FileMode::Open, FileAccess::Read);
130134
$json = await($file->readAsync($file->Length));
131135
$data = json_decode($json);
132136

src/app/core/extension/extension.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h3>Extension class</h3>
5151
<br>
5252
<h3>Calling the extension method</h3>
5353
<p class="text-justify">
54-
To call an extension method as if it were an instance method on a particular extended class, the extension class must be brought into the scope of the same file where that instance calls the extension method, using the keyword <code>use</code>
54+
To call an extension method as if it were an instance method on a particular extended class, the extension class must be brought into the same scope where that instance calls the extension method, using the keyword <code>use</code>
5555
</p>
5656
<pre><code class="language-php">&lt;?php
5757

src/app/core/overview/overview.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1>Overview</h1>
1111
DevNet Core is the heart of the DevNet framework, and all of its components rely on it. It is a base class library that provides several fundamental features that make it easier to develop applications in PHP. These features include:
1212
</p>
1313
<ul>
14-
<li>Computed Properties</li>
14+
<li>Accessor Properties</li>
1515
<li>Extension Methods</li>
1616
<li>LINQ Methods</li>
1717
<li>Generic Types</li>
@@ -22,7 +22,7 @@ <h1>Overview</h1>
2222
<br>
2323
<h3>Installation</h3>
2424
<p>
25-
If you have installed any of the DevNet packages in your system or project, then you already have the DevNet Core. However, you can still install DevNet Core as a third-party library to work with any frameworks by running the following command in the terminal using composer:
25+
If you have installed any of the DevNet packages in your system or project, then you already have the DevNet Core. However, you can still install DevNet Core as a third-party library to work with any PHP project by running the following command in the terminal using composer:
2626
</p>
2727
<pre><code class="language-shell">composer require devnet/core</code></pre>
2828
</article>

src/app/core/properties/properties.component.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
</div>
66
<div id="content" class="flex-grow-1" style="width: 400px;">
77
<article>
8-
<h1>Computed Properties</h1>
8+
<h1>Accessor Properties</h1>
99
<hr>
1010
<p>
11-
A computed property is a property that doesn't store a value directly. Instead, it uses a getter and a setter method to retrieve and set other properties indirectly.
11+
Accessor properties are methods that look like regular data properties from the outside but are invoked as methods internally when accessed as properties. This allows us to define custom logic for reading and writing the values of an object's properties, with more control over the property's behavior, such as how to validate or modify the input or output, unlike the data properties, which directly store a fixed value.
1212
</p>
13-
<h3>Getter</h3>
1413
<p>
15-
A getter is a function bound to a computed property and returns a value when that property is looked up.
14+
To enable the accessor property feature, you need to include the trait <code>DevNet\System\PropertyTrait</code> in your class.
1615
</p>
16+
<h3>Getter Accessor</h3>
1717
<p>
18-
To use a getter for a computed property in DevNet, you need first to include the trait <code>DevNet\System\PropertyTrait</code> in your class to enable this feature, then define the computed property as a method prefixed with <code>get</code> that returns a value.
18+
The getter accessor is a function bound to a computed property and returns a value when that property is looked up.
19+
</p>
20+
<p>
21+
Here is an example that shows how to define a getter accessor property, which is a method that has a property name prefixed with <code>get_</code> accessor and return a value.
1922
</p>
2023
<pre><code class="language-php">&lt;?php
2124

@@ -30,7 +33,7 @@ <h3>Getter</h3>
3033
public string $FirstName;
3134
public string $LastName;
3235

33-
// Defining the getter computed property.
36+
// Computed property with getter accessor.
3437
public function get_FullName(): string
3538
&lcub;
3639
return $this->FirstName . ' ' . $this->LastName;
@@ -53,12 +56,12 @@ <h3>Getter</h3>
5356
print($person->FullName); // Output: John Doe
5457
</code></pre>
5558
<br>
56-
<h3>Setter</h3>
59+
<h3>Setter Accessor</h3>
5760
<p>
58-
A setter is a function bound to a computed property and will be called when there is an attempt to set that property.
61+
The setter accessor is a function bound to a computed property and will be called when there is an attempt to set that property.
5962
</p>
6063
<p>
61-
To use a setter for a computed property, you need to include the trait <code>DevNet\System\PropertyTrait</code> in your class to enable this feature, then define the computed property as a method prefixed with <code>set</code> that has a value as a parameter.
64+
The following example shows how to define a setter accessor property as a method prefixed with <code>set_</code> accessor and take a value parameter to set object.
6265
</p>
6366
<pre><code class="language-php">&lt;?php
6467

@@ -73,7 +76,7 @@ <h3>Setter</h3>
7376
public string $FirstName;
7477
public string $LastName;
7578

76-
// Defining the setter computed property.
79+
// Computed property with setter accessor.
7780
public function set_FullName(string $value): void
7881
&lcub;
7982
$segments = explode(' ', $value, 2);
@@ -83,7 +86,7 @@ <h3>Setter</h3>
8386
}
8487
</code></pre>
8588
<p>
86-
And here how to set he computed property:
89+
And here how to set the computed property:
8790
</p>
8891
<pre><code class="language-php">&lt;?php
8992

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ <h3>Creating a migration</h3>
2626

2727
namespace Application\Migrations;
2828

29-
use DevNet\Entity\Migration\AbstractMigration;
30-
use DevNet\Entity\Migration\MigrationBuilder;
29+
use DevNet\Entity\Migrations\Migration;
30+
use DevNet\Entity\Migrations\MigrationBuilder;
3131

32-
class InitialMigration extends AbstractMigration
32+
class InitialMigration extends Migration
3333
&lcub;
3434
/**
3535
* Schema definitions will be executed when the migration is upgraded.
@@ -64,10 +64,10 @@ <h4>Creating the database Schema</h4>
6464

6565
namespace Application\Migrations;
6666

67-
use DevNet\Entity\Migration\AbstractMigration;
68-
use DevNet\Entity\Migration\MigrationBuilder;
67+
use DevNet\Entity\Migrations\Migration;
68+
use DevNet\Entity\Migrations\MigrationBuilder;
6969

70-
class InitialMigration extends AbstractMigration
70+
class InitialMigration extends Migration
7171
&lcub;
7272
public function up(MigrationBuilder $builder): void
7373
&lcub;
@@ -98,7 +98,7 @@ <h4>Creating the database Schema</h4>
9898
public function down(MigrationBuilder $builder): void
9999
&lcub;
100100
// if the constraint ON DELETE is configured as "strict" and which is the default configuration,
101-
// the child table must be droped before the parent table, otherwise will throw an error.
101+
// the child table must be dropped before the parent table, otherwise will throw an error.
102102
$builder->dropTable('UserRole');
103103
$builder->dropTable('User');
104104
$builder->dropTable('Role');
@@ -114,10 +114,10 @@ <h4>Updating the database schema</h4>
114114

115115
namespace Application\Migrations;
116116

117-
use DevNet\Entity\Migration\AbstractMigration;
118-
use DevNet\Entity\Migration\MigrationBuilder;
117+
use DevNet\Entity\Migrations\Migration;
118+
use DevNet\Entity\Migrations\MigrationBuilder;
119119

120-
class AlterMigration extends AbstractMigration
120+
class AlterMigration extends Migration
121121
&lcub;
122122
public function up(MigrationBuilder $builder): void
123123
&lcub;
@@ -161,10 +161,10 @@ <h4>Seeding the database</h4>
161161

162162
namespace Application\Migrations;
163163

164-
use DevNet\Entity\Migration\AbstractMigration;
165-
use DevNet\Entity\Migration\MigrationBuilder;
164+
use DevNet\Entity\Migrations\Migration;
165+
use DevNet\Entity\Migrations\MigrationBuilder;
166166

167-
class SeedMigration extends AbstractMigration
167+
class SeedMigration extends Migration
168168
&lcub;
169169
public function up(MigrationBuilder $builder): void
170170
&lcub;
@@ -197,6 +197,9 @@ <h3>Applying migrations</h3>
197197
And here is an example shows how to run the migrate command targeting the migration that we created earlier:
198198
</p>
199199
<pre><code class="language-shell">devnet migrate --target 20230701082859_InitialMigration</code></pre>
200+
<blockquote class="alert alert-warning">
201+
<b>Important:</b> Make sure to specify the database configuration in the <samp><b>settings.json</b></samp> before running the <code>migrate</code> command or pass it to the command as parameters using the options: <code>--provider</code> and <code>--connection</code>.
202+
</blockquote>
200203
<br>
201204
<h4>Applying all migrations</h4>
202205
<p>

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ <h3>Connecting to the Database</h3>
138138
<pre><code class="language-php">&lt;?php
139139

140140
use Application\Models\BlogContext;
141-
use DevNet\Entity\MySql\MySqlDataProvider;
142141
use DevNet\Entity\EntityOptions;
142+
use DevNet\Entity\MySql\MySqlDataProvider;
143143

144144
$options = new EntityOptions();
145145
$options->ProviderType = MySqlDataProvider::class;
146-
$options->ConnectionString = "//user:[email protected]/blog";
146+
$options->ConnectionString = "//username:[email protected]/blog";
147147

148148
$blog = new BlogContext($options);
149149
$posts = $blog->Posts;
@@ -187,29 +187,29 @@ <h4>Connection String</h4>
187187
<br>
188188
<h3>Registering the EntityContext</h3>
189189
<p>
190-
You can register Entity ORM as a reused service that will be injected into your application using the Extension method <code>ServiceCollectionExtensions::addEntityContext()</code> inside the method <code>WebHostBuilder::register()</code>, as shown in the following code example:
190+
It is recommended that you register the Entity ORM as a reusable service to be injected into your application using the <code>ServiceCollectionExtensions::addEntityContext()</code> Extension method, which is called within the <code>WebHostBuilder::register()</code> method, with the use of the configuration provider that gets the database configuration from the <samp>"settings.json"</samp> file as shown in the following code example:
191191
</p>
192192
<pre><code class="language-php">&lt;?php
193193

194194
namespace Application;
195195

196+
use Application\Models\BlogContext;
196197
use DevNet\Web\Hosting\WebHost;
197198
use DevNet\Web\Extensions\ApplicationBuilderExtensions;
198199
use DevNet\Web\Extensions\ServiceCollectionExtensions;
199-
use DevNet\Entity\MySql\MySqlDataProvider;
200-
use Application\Models\BlogContext;
201200

202201
class Program
203202
&lcub;
204203
public static function main(array $args = [])
205204
&lcub;
206205
$builder = WebHost::createDefaultBuilder($args);
207-
$builder->register(function ($services) &lcub;
206+
$configuration = $builder->Configuration;
207+
$builder->register(function ($services) use ($configuration) &lcub; //;
208208
// adding EntityContext
209209
$services->addEntityContext(BlogContext::class,
210210
function ($options) &lcub;
211-
$options->ProviderType = MySqlDataProvider::class;
212-
$options->ConnectionString = "//user:[email protected]/blog";
211+
$options->ProviderType = $configuration->getValue('Database:ProviderType');
212+
$options->ConnectionString = $configuration->getValue('Database:ConnectionString');
213213
}
214214
);
215215
});
@@ -218,18 +218,26 @@ <h3>Registering the EntityContext</h3>
218218
}
219219
</code></pre>
220220
<p>
221-
You can then get the EntityContext using the constructor injection to add the EntityContext to the controller class and use it in the controller methods like the following example:
221+
In the <samp>"settings.json"</samp> file, you need to set the database configuration, like in the following example:
222+
</p>
223+
<pre><code class="language-json">"Database": &lcub;
224+
"ProviderType": "DevNet\\Entity\\MySql\\MySqlDataProvider",
225+
"ConnectionString": "//username:[email protected]/blog"
226+
}
227+
</code></pre>
228+
<p>
229+
Then, you can get the <code>EntityContext</code> using the controller constructor injection, like this:
222230
</p>
223231
<pre><code class="language-php">&lt;?php
224232

225233
namespace Application\Controllers;
226234

227-
use DevNet\Web\Endpoint\ActionController;
235+
use DevNet\Web\Endpoint\Controller;
228236
use DevNet\Web\Endpoint\IActionResult;
229237
use DevNet\Web\Endpoint\Route;
230238
use Application\Models\BlogContext;
231239

232-
class BlogController extends ActionController
240+
class BlogController extends Controller
233241
&lcub;
234242
private BlogContext $blog;
235243

@@ -238,7 +246,7 @@ <h3>Registering the EntityContext</h3>
238246
$this->blog = $blog;
239247
}
240248

241-
#[Route("/")]
249+
#[Route("/blog")]
242250
public function index(): IActionResult
243251
&lcub;
244252
$this->view(['posts' => $this->blog->Posts]);

src/app/home/home.component.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
<div class="container">
2-
<div class="d-flex flex-column justify-content-center text-center" style="height: 75vh">
3-
<h1 class="display-3 mx-auto">DevNet Framework</h1>
4-
<p class="lead w-75 mx-auto">
5-
A free open-source software, and cross-platform, inspired by ASP.NET Core, built in PHP for rapid
6-
application development, APIs, console and modern web application with high performance.
7-
</p>
8-
<div class="d-grid gap-2 d-md-flex justify-content-center">
9-
<a class="btn btn-danger px-4 me-md-2" routerLink="/docs">Documentation</a>
10-
<a class="btn btn-outline-secondary px-4" href="https://github.com/DevNet-Framework">View on
11-
GitHub</a>
12-
</div>
1+
<div class="d-flex flex-column justify-content-center text-center py-4 my-5">
2+
<h1 class="display-3 mx-auto">DevNet Framework</h1>
3+
<p class="lead w-75 mx-auto">
4+
A free open-source software, and cross-platform, inspired by ASP.NET Core, built in PHP for rapid
5+
application development, APIs, console and modern web application with high performance.
6+
</p>
7+
<div class="d-grid gap-2 d-md-flex justify-content-center">
8+
<a class="btn btn-danger px-4 me-md-2" routerLink="/docs">Documentation</a>
9+
<a class="btn btn-outline-secondary px-4" href="https://github.com/DevNet-Framework">View on
10+
GitHub</a>
1311
</div>
1412
</div>

src/app/security/antiforgery/antiforgery.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ <h3>X-CSRF-TOKEN</h3>
8787
namespace Application\Controllers;
8888

8989
use DevNet\System\Linq;
90+
use DevNet\Web\Endpoint\Controller;
9091
use DevNet\Web\Endpoint\IActionResult;
91-
use DevNet\Web\Endpoint\ActionController;
9292
use DevNet\Web\Endpoint\Route;
9393
use DevNet\Web\Security\Authorization\Authorize;
9494
use DevNet\Web\Security\Tokens\Csrf\Validate;
9595

9696
#[Authorize]
97-
class AccountController extends ActionController
97+
class AccountController extends Controller
9898
&lcub;
9999
#[Route(path: '/account/edit/&lcub;id}', method: 'GET')]
100100
public function edit(int $id): IActionResult

0 commit comments

Comments
 (0)