Init Framework
Init Framework is a simple PHP Web framework for building Web Applications and APIs.

What can Init Framework be used for
Almost any application can be built on Init Framework. Here and more imaginable applications are what you can build with of Init Framework :
  • A simple Web Application
  • An e-Commerce application
  • Content Management Applications
  • Blogs and Forums
  • Business Websites
  • API based applications
  • and more ...

How it works
When a Http Request is made, the application first locates the Routes in the 'routes/' directory. If the requested url is tied to a Defined Route, the controller method tied to that route is called. If the requested url is not tied to any defined route, An Error 404 is returned.
When the -Controller- method is called, all the url parameters that came with the Get Request or the Post Request is passed to it as an associative array. -Getting Data from a Request-
It is in the controller method that you enter your custom codes; you can either call the View to display a page. You can manipulate database records with the Models; you can also Authenticate Requests using the Auth Provider. All these you can do and many from your controller method. With the View class, you can return JSON data in the case of an API application.

Features
Some of the Frameworks Features include:
  • Organized file structure
  • Pretty Url
  • Routing
  • MVC Structured
  • Scaffolding
  • Object Oriented
  • Eloquent Database Type
  • View Directives
  • Authentication

File Structure
Init Framework has a simple and standard file structure.

Init Framework File Structure

Pretty Url
Init Framework uses the .htaccess file to return every route to the 'public/index.php' from where it opens the controller tied to the route. Route definition gives you the ability to define how your url would look like.

Routing
Define every route in your application in the route files, tie the route to a Controller Method.

MVC
Init Framework is built to split your application into seperate layers (i.e the model, view and the controller) that can work seperately and produce the same result, therefore allowing for team work.

Scaffolding
The 'init.engine.php' file helps to generate model classes, controller classes and view templates. It also generates Provider classes for you.
Example
localhost/myapp/init.engine.php
The init.engine.php file has been granted access in the .htaccess file
RewriteRule ^init.engine.php - [NC,L]
On a live server, you can comment it out by adding the hash character (i.e #) to the beginning of the line.
# RewriteRule ^init.engine.php - [NC,L]

OOP
Init Framework is fully Object Oriented.

Eloquent Database Type
Init Framework provides a simple way to access and work with the database from your Model. Update the database details in the 'config.php' file. Model files are in the 'models/ directory.

View Directives
Init Framework provides solid View Directives that helps you manipulate data in the view. It provides Conditional View Directives.
Example
@if (isset($user) == true)
 <div>{{$user}}</div>
@else
 <div>
  <a href="{{route('login')}}">Login</a>
 </div>
@endif
And it also provides Loop View Directives
Example
@foreach ($fruits as $fruit)
<li>{{$fruit}}</li>
@endforeach

Authentication
Init Framework provides authentication by adding a table to your database to help authenticate users.
It provides a provider class that you can interact with by importing them into your controller class to authenticate users.

Installation and Setup
You can skip this section of you have these installed on your device : An Apache Server, A Web Browser and a Code Editor.

Requirement
To use Init Framework to develop applications, it requires the following software :
  • A code editor like Visual Studio Code, Sublime Text, Atom etc.
  • An Apache server like Xampp, Wamp for Windows OS, Lamp for Linus OS, Mamp for Mac OS or Xampp for any Operating System.
  • A Web Browser.
  • What PHP version does the application run on??

Installation
If you do not have any of the required software installed on your device, go ahead with downloading and installing them.

Setup
To start a new application,
  1. visit https://www.initframework.com/engine
  2. Enter your application name and Create New Application.
  3. Download the generated file.
  4. Move the file to your htdocs, www or public_html directory and unzip it.
  5. Then Go to your browser and enter your domain (i.e `localhost/yourApplicationName` or `www.yourApplicationName.com`). It will show up the Welcome Page
To start creating application files, use the Init Engine in `init.engine.php` to generate Provider class files, model files, view files and controller files.

Routing
As stated earlier, Http Requests are possible if the requested url is tied to a particular route. A route could be defined for web in the `routes/web.php` file or for api in the `routes/api.php` file.
In any of the route files, there are two Http Verbs that are available for use in Init Framework and that is the Get Http Verb and the Post Http Verb.

Defining Routes
To define a route, call the `get` or `post` static method of the `Route` class, passing along the required url, the unique name for the route and the controller method handling the route.
Syntax
Route::get('/uri','name','Controller@Method');
To define the route for an a page E.g About us page
Example
Route::get('/about','about','HomeController@about');
For the example above, the url in the web browser would be
https://www.myapp.com/about
To define the route for a form submission, E.g A post from a subscribe form
Example
Route::post('/subscribe.submit','subscribe.submit','HomeController@subscribeSubmit');
`HomeController` is the controller name and `about` is the method that is called whenever the url is matched.
Example
class HomeController extend Controller
{
 public function about(array $data)
  {
   // Enter your code here...
  }
}
The above code is an example of a HomeController with the about method.
Note
The name of every route must be unique, so that it can referenced in the code.
Note
Do not delete or modify the default home route that comes with every application.
Route('/','home','HomeController@index');

Routes with Url Parameters
Url parameters can be added to routes by adding placeholders to the route uri.
Example
Route::get('/dashboard/{user}','dashboard','DashboardController@index');
Routes can also accept multiple url parameters
Example
Route::get('/posts/{id}/{title}','blog.post','PostController@post');
Routes defined with Post Http Verb can also accept url parameters.
Example
Route::post('/post/{id}/update','post.update','PostController@update');
Note
Note that the url variable placeholders are replaced with the exact value.
Also note that if the exact values contain the forward slash character (i.e /), it would be replaced with an underscore character (i.e _ ).

Routing from the View
To route from page to page, the `a tag` is used and the directory of the page is added to the `href attribute` but to route to a page in Init Framework, you call the `route` function and pass in the name of the route as a parameter.
Syntax
route('unique.name')
To route to the About page
Example
<a href="{{route('about')}}">About</a>
If the route is expecting url parameters, pass in the parameters as an associative array as the second argument in the route function.
Example
<a href="{{route('blog.post',['id'=>1,'title'=>'A story about toys'])}}">Post</a>
You can also use the `@stmt` -View Directive- to make the code neater
Example
@stmt $link = route('blog.post',['id'=>1,'title'=>'A story about toys']);
<a href="{{$link}}">Post</a>
Note
The key of the associative array must be the placeholder used when defining the route in the route uri.
Route::get('/posts/{id}/{title}','blog.post','PostController@post');

---

@stmt $link = route('blog.post',['id'=>1,'title'=>'A story about toys']);

Submitting Forms
Forms can be submitted using the post method only. And the uri for the `action attribute` is gotten with the route function.
Example
<form action="{{route('subscribe')}}" method="POST">
...
</form>
And it also provides Loop View Directives
Note
Assigning a route defined with a Get Http verb (i.e Route::get(...) ) to Post Http Request would result in error.

Defining API Routes
For API routes, define the routes in `setApiRoute()` function in the `routes/api.php` directory.
Just to differentiate api routes from other web routes, prepend `/api` to the route uri and also prepend `api.` to the name.
Example
Route('/api/login','api.login','LoginController@auth');
Note
Prepending `/api` and `api.` to the route uri and the route name respectively is not compulsory.

Controllers
Every route uri must be tied to a controller before it can be fully functional. To add a new controller to your `controllers/` directory, visit `localhost/myapp/init.engine.php`. Enter the controller name and click add controller.

Controller Methods
A controller class can have as many methods as possible. They just have to follow the syntax.
Syntax
public function methodName(array $data)
{
 ...
}
The `public` access modifier is used because the class would be accessible from the route.
A method can be private to a controller by changingthe access modifier to `private`.
Syntax
private function methodName()
{
 ...
}
You can define what argument you want for your private method.

Url Parameters
Every method that is accessible to the Route is must be publicly accessible; And any method that is expecting values from the Url must have `(array $data)` arguments only.
This `$data` variable is an associative array, and the key in the array is the placeholder set in the route directory for Get Http Request or the Post Http Request.
Note
Note that Post Http Request doesn't require placeholders for its expected values.
So if a controller method was expecting a value named "userId", in the controller, it would be gotten as $data['userId'].
Example
$userId = $data['userId'];

Calling Controller Methods from another Controller Method
You can call controller methods from your controller method by just calling the static Route method `call`.
Example
Route:call('HomeController@login');

Rendering a View File
To open a view file, use the static View function `show`.
Syntax
View::show('filename.html');
Example
View::show('login.html');

Passing Parameters to the View
Controllers can call view files, and can also send parameters to these view files.
To send parameters to the views, use the static View method `with` and pass in an associative array (i.e key-value pair) of the parameter.
Syntax
View::with(associative-array)->show(filename.html);
Example
View::with([
 "firstname"=>"Ada"
 "lastname"=>"Obi",
 "age"=>21
])->show('dashboard.html');
Note
When sending an array to the view, encode as Json before sending it.
Example
$fruits = ["Apple","Banana","Coconut"];

// convert to Json
$fruits = json_encode($fruits);

View::with([
 "fruits"=>$fruits
])->show('fruits.html');

Returning Data as JSON
To return data to be used for an AJAX request, use the static View method `asJson`. This is also used to return response to API requests.
Syntax
View::asJson(associative-array)
Example
View::asJson([
 "firstname"=>"John",
 "lastname"=>"Okafor"
]);

Logging Parameters for several Views
To save data to be used in several view files like the user's full name, use the static View method `log`.
Syntax
View::log(associative-array)
Example
View::log([
 "firstname"=>"John",
 "lastname"=>"Okafor"
]);
Note
The `with` method saves data to be used by the file to be loaded, while the `log` method saves data that is to be used in several view files.

Models
Models are classes that represent each table in the database. With the models - you can insert, read, update and delete datas in the database. To work with models, update the database details in the `config.php` file. You can create model classes with the init engine by redirecting to `init.engine.php`, enter the table name, and enter the model name and cleck Create Model. The model file would be in the `models/` directory. The model class inherits the Core Model class. You can manipulate the database by calling any of the model functions below.

Model Methods
Create
Syntax
create(array $inputs) : bool
A method used to create a new record in the database.
Example
$this->create([
 "firstname"=>"Ada",
 "lastname"=>"Okafor"
]);

Read
Syntax
read(string $fields) : array
A method for reading data from the database.
Example
$this->read("firstname, lastname");

Read Join
Syntax
readJoin(string $joinTables, string $joinFields) : array
A method to read data from multiple tables. This method is mostly used alongside with the where() method.
Example
$this->readJoin("user_tbl,chat_tbl", "user_tbl.username, chat_tbl.messages");

Update
Syntax
update(array $updates) : bool
A method to update one or many records.
Example
$this->update([
 "firstname"=>"Ola",
 "lastname"=>"Adeniyi"
]);

Delete
Syntax
delete() : bool
A method to delete one or many records.
Example
$this->delete();

Where
Syntax
where(string $conditions) : Model
A method that sets the condition for a query. This method is mostly used with other methods.
Example
$this->where("firstname = 'Obi'");
... $this->where("no_users > 2");
And when using 'where' with with the readJoin method.
$this->where("user_tbl.username = chat_tbl.username");

Misc
Syntax
misc(string $stmts) : Model
A method that sets all the miscellaneous conditions of a query like the LIMIT, OFFSET, GROUP BY, ORDER BY, etc...
Example
$this->misc("LIMIT 1");
$this->misc("ORDER BY firstname");

Query Function
Syntax
queryFunction(string $function, string $field) : array
A method that executes a function on the data of a field in the table.
Example
$this->queryFunction("AVG", "amount");

Exist
Syntax
exist() : bool
A method that returns the result of a condition.
Example
$this->exist();

Last Id
Syntax
lastId() : int
A method to get the last inserted id after a create method have been called.
Example
$this->lastId();

Rows Affected
Syntax
rowsAffected() : int
A method to get the number of rows affected after an update() method have been called.
Example
$this->rowsAffected();

Begin Transaction
Syntax
beginTransaction() : void
A method that is used to pause auto-commit.
Example
$this->beginTransaction();

Commit
Syntax
commit() : void
A method that is used to commit all the executed queries.
Example
$this->beginTransaction();

Rollback
Syntax
rollback() : void
A method to rollback back all the executed queries.
Example
$this->rollback;

Custom
Syntax
custom(string $query, bool $returnResult) : array
A method to execute your own custom query.
Example
$this->custom("SELECT * FROM users_tbl", true);

Views
Views are HTML codes that display web pages on the browsers. Init Framework provides View Directives that are used to manipulate data in the view. The Directives are conditional and iterative (i.e it supports looping).

Echo Directive
To show these parameters in the view, use the Echo View Directive.
Syntax
{{$variable}}

Parameters from the Controllers
Parameters are sent from the controllers to the views as associative arrays
Example
View::with([
 "firstname"=>"Ada",
 "lastname"=>"Obi"
])->show("dashboard.html");
So to get the firstname and the lastname parameter sent from the controller, we do this.
Example
<p>Welcome {{$firstname}} {{$lastname}}</p>

Directives Syntax
Most View Directives have similar syntax. The Directives must start with the at character (i.e @), followed by the Directive name and then the statement
Syntax
@Directive Statement
Note
Every View Directive must have an opening tag and a closing tag.
Example
@if ($username == "Wale")
 ...
@endif

Conditional Directives
Conditional statments are used to execute different blocks of codes based on different conditions. The conditional Directives provided by Init Framewok are:

@if-@endif Directive
The @if-@endif Directive is used to execute some codes if the condition is met.
Syntax
@if (condition)
 ...
@endif
Example
@if ($name == "Obi")
 <p>Obi is a boy</p>
@endif

@if-@else-@endif Directive
The @if Directive is used to execute some codes if the condition is met; And if the condition is not met, the @else Directive is used to execute some other codes.
Syntax
@if (condition)
 ...
@else
 ...
@endif
Example
@if ($name == "Obi")
 <p>Obi is a boy</p>
@else
 <p>{{$name}} is not Obi</p>
@endif

@if-@elseif-@else-@endif Directive
The @if Directive is used to execute some codes if the condition is met; And if the condition is not met, the @elseif Directive is used to execute another some other codes if its own condition is met. Then the @else Directive is used to execute some other codes if all conditions are not met.
Syntax
@if (condition)
 ...
@elseif (condition)
 ...
@else
 ...
@endif
Example
@if ($name == "Obi")
 <p>Obi is a boy</p>
@elseif ($name == "Ada")
 <p>Ada is a girl</p>
@else
 <p>{{$name}} is neither Obi nor Ada</p>
@endif

@switch, @case, @break, @default, @endswitch
The @switch Directive is used to select one of many blocks of codes in the several @case Directive.
Syntax
@switch (n)

 @case label1:
  ...
 @break

 @case label2:
  ...
 @break

 @default
  ...
 @break

@endswitch
Example
@switch ($name)

 @case "Obi"
  <p>Obi is a boy</p>
 @break

 @case "Ada"
  <p>Ada is a girl</p>
 @break

 @default
  <p>{{$name}} is neither Obi nor Ada</p>
 @break

@endswitch

Iterative Directives
Iterative statements are used to execute a block of code when a particular condition is true. The iterative Directives provided by Init Framework are:

@for-@endfor Directive
The @for-@endfor Directive is used to execute a block of code when you know in advance the number of times the code should loop.
Syntax
@for (initiate counter; test condition; increment counter)
 ...
@endfor
Example
@for ($i = 1; $i <= 5; $i++)
 <li>{{$i}}. Obi is a boy</li>
@endfor

@foreach-@endforeach Directive
The @foreach-@endforeach Directive works for arrays only, and is used to loop through the key/value pair of the array.
Syntax
@foreach ($fruits as $fruit)
 ...
@endforeach
Example
@foreach ($fruits as $fruit)
 <li>I love {{$fruit}}. 😋</li>
@endforeach

@while-@endwhile Directive
The @while-@endwhile Directive is used to execute a block of code as long as the specified condition is true.
Syntax
@while (condition)
 ...
@endwhile
Example
@while ($i < 5)
 <li>I have {{$i}} friends.</li>
@endwhile

@do-enddo Directive
The @do-enddo Directive will execute a block of code once, it will check the condition, and repeat the loop while the specified condition is true.
Syntax
@do
 ...
@enddo (condition)
Example
@do
 <li>I have {{$i}} friends.</li>
@enddo ($i < 5)

@stmt Directive
The @stmt Directive is an ubiquitous Directive that can be used to carry out any other necessary php code but it must be delimited by a semi-colon character (i.e ;) after every statement.
Syntax
@stmt statements;
Example
@stmt $name = "Ebelechukwu";

@import Directive
The import Directive is used to import other HTML files into the current HTML file.
Syntax
@import filename
Example
@import header.html

Nested Statements
View Conditional Directives can be nested as in normal PHP codes.
Example
@for (int $i = 0; $i < 10; $i++)
 @if ($i == 0)
  <p>Zero</p>
 @endif
@endfor

Commenting Directives
When commenting in regular HTML codes, it is proper to comment codes like this
Example
<!-- <h1>Welcome to MyApp</h1> -->
The above code is an example of a single line comment snippet. An example of a multi-line comment is this
Example
<!-- <h1>
 Welcome to MyApp
</h1> -->
But when using View Directives in your HTML for further functionalities like this:
Example
@foreach ($fruits as $fruit)  <li>{{$fruit}}</li> @endforeach
Commenting of this lines of cides is done only singly (i.e single line commenting) like this:
Example
<!-- @foreach ($fruits as $fruit) -->
 <!-- <li>{{$fruit}}</li> -->
<!-- @endforeach -->
And not like this:
Example
<!-- @foreach ($fruits as $fruit)
 <li>{{$fruit}}</li>
@endforeach -->

Routing from the View
To route from page to page, the `a tag` is used and the directory of the page is added to the `href attribute` but to route to a page in Init Framework, you call the `route` function and pass in the name of the route as a parameter.
Syntax
route('unique.name')
To route to the About page
Example
<a href="{{route('about')}}">About</a>
If the route is expecting url parameters, pass in the parameters as an associative array as the second argument in the route function.
Example
<a href="{{route('blog.post',['id'=>1,'title'=>'A story about toys'])}}">Post</a>
You can also use the `@stmt` -View Directive- to make the code neater
Example
@stmt $link = route('blog.post',['id'=>1,'title'=>'A story about toys']);
<a href="{{$link}}">Post</a>
Note
The key of the associative array must be the placeholder used when defining the route in the route uri.
Example
Route::get('/posts/{id}/{title}','blog.post','PostController@post');

---

@stmt $link = route('blog.post',['id'=>1,'title'=>'A story about toys']);

Accessing Resources
To access resources in the `resources/` directories like `imgs/`, `/js` and `/css` directory to get files, call the View global function `resources` and pass the filepath of the required file.
Syntax
resources(filepath)
And to show the resources in the view, use the Echo Directive.
Example
For Images
<link rel="shortcut icon" href="{{resources('imgs/favicon.ico')}}" type="image/x-icon">
For Css
<link rel="stylesheet" href="{{resources('css/main.css')}}">
For Javascript
<script src="{{resources('js/main.js')}}"></script>

Accessing Storage
To access storage files in the `storage/` directory, call the View global function `storage` and pass the filepath of the required file.
Syntax
storage(filepath)
And to show the storage file in the view, use the Echo Directive.
Example
<img src="{{storage('/storage/ade.png')}}" alt="Ade" />

Forms
A Form is an HTML element that is used to collect data from a user.

Submitting Forms
In Init Framework, a form can only use the POST method and not the Get method; And the uri for the `action attribute` is gotten with the route function.
Example
<form action="{{route('subscribe')}}" method="POST">
 ...
</form>
Note
Assigning a route defined with a Get Http verb (i.e Route::get(...) ) to Post Http Request would result in error.

Providers
Providers are classes that can be used by different controllers in the application. A developer can write his own provider.

Auth Provider
The Auth Provider class is an aunthentication and authorization service provider for Init applications. The Auth Provider does not come defaultly with a new project. To add the Auth Provider, update the database details in the `config.php` file. Go to the local engine and click `Add Authentication`.
Note
The Auth method are static methods, so they are accessed using double colon (i.e ::). An
Example
Auth::user();

Auth Methods
Add Auth
Syntax
addAuth(string $userId, string $role)
A method that is used to register a user for Authentication and Authorization.
Example
Auth::addAuth($username, "SALESREP");

Check
Syntax
check() : bool
A method that is used to check if a user is authenticated.
Example
if (Auth::check() == true) {
 ...
}

Guard
Syntax
guard(string $role) : bool
A method that is used to guard a segment of the application by checking the `role` of the authenticated user.
Example
if (Auth::guard("ADMIN") == true) {
 ...
}

Login
Syntax
login(string $userId, string $role, bool $remember)
A method that is used to log a user in. The remember parameter is true if the user wants to be remembered whenever he opens the application.
Example
Auth::login($username, "ADMIN", true)

Login API
Syntax
loginApi(string $userId)
A method that is used to login a device t be registered for web services.
Example
Auth::loginApi($username);

Logout
Syntax
logout()
A method that is used to log a user out.
Example
Auth::logout();

Logout API
Syntax
logoutApi(string $userId)
A method that is used to logout a device that is registered for web services.
Example
Auth::logoutApi($username);

User
Syntax
user()
A method that is used to get the currently authenticated user.
Example
$userId = Auth::user();

View Check
On the view template, you can check if the user is authenticated by calling the check function.
Example
@if (check() == true)
 ...
@endif

View Guard
On the view template, you can guard a section of the code by using the guard function.
Example
@if (guard("ADMIN") == true)
 ...
@endif
Note
The View Check and the View Guard would only work if Authentication has been added to the application.

Validator Provider
The Validator Provider class is a service provider that helps to validate a user's input. The methods are divided into the validation section an the error section.

Validator Methods
Int
Syntax
int(string $field, $value, array $options = [], bool $allowOctal = false, bool $allowHex = false)
A method that is used to validate an integer field.

String
Syntax
string(string $field, $value, array $options = [])
A method that is used to validate a string field.

Email
Syntax
email(string $field, $value, array $options = [], bool $emailUnicode = false)
A method that is used to validate an email field.

IP Address
Syntax
ip(string $field, $value, array $options = [], bool $ipv4 = false, bool $ipv6 = false, bool $noPrivRange = false, bool $noResRange = false)
A method that is used to validate an IP address.

URL
Syntax
url(string $field, $value, array $options = [], bool $schemeRequired = false, bool $hostRequired = false, bool $pathRequired = false, bool $queryRequired = false)
A method that is used to validate a URL path.

Domain
Syntax
domain(string $field, $value, array $options = [], bool $hostname = false)
A method that is used to validate the domain of a URL path.

Boolean
Syntax
boolean(string $field, $value, array $options = [], bool $nullOnFailure = false)
A method that is used to validate a boolean field.

Float
Syntax
float(string $field, $value, array $options = [], bool $allowThousand = false)
A method that is used to validate a floating point field.

Mac Address
Syntax
mac(string $field, $value, array $options = [])
A method that is used to validate a mac address.

Regular Expression
Syntax
regexp(string $field, $value, string $pattern ,array $options = [])
A method that is used to set the validation rules for a field with regular explression.

Error Methods
has Error?
Syntax
hasError() : bool
A method that is used to find out if any error occured during validation.

Get First Error
Syntax
getFirstError() : string
A method that is used to get the first error that occured during validation.

Get Last Error
Syntax
getLastError() : string
A method that is used to get the last error that occured during validation.

Get Field Errors
Syntax
getFieldErrors(string $field) : array
A method that is used to get all the errors that occured on a particular field.

Get Field First Error
Syntax
getFieldFirstError(string $field) : array
A method that is used to get all the errors that occured on a particular field.

Get Field Last Error
Syntax
getFieldLastError(string $field) : array
A method that is used to get the last error that occured in a field.

Get Errors By Fields
Syntax
getErrorsByFields() : array
A method that is used to get all errors and the fields on which they occured in an associative array.

Get All Field's First Error
Syntax
getAllFieldsFirstError() : array
A method that is used to get the first error of all fields.

Get All Field's Last Error
Syntax
getAllFieldsLastError() : array
A method that is used to get the last error of all fields.

Uploader Provider
The Upload Provider class is a service provider that helps with file uploading.

Uploader Methods
Constructor
Syntax
__construct(string $fieldname, string $newFilename = "", string $storageDir = "/storage/")
The constructor has one required parameter and two optional parameters, the $fieldname is the name of the file, the $newFilename is the name the file is to be stored with, the $storageDir is the storage directory of the file. By default, the storage directory is "/storage/", you can leave this as it is or append it.
Note
The storage directory must always be a sub-directory of the default one.

Validate
Syntax
validate(string $fieldLabel = "", array $fileTypes, int $maxsize = null, $minsize = null)
A method that validates the properties of the file to be uploaded. The $fieldLabel is the field name that helps to generate the error message, $fileTypes is an array of all the file types that the file can have, $maxsize is the maximum filesize required of the file and $minsize is the minimum filesize required of the file.

Errors
Syntax
errors()
A method that returns an array of errors if there was any error when validating the file. If there was no error, it returns a false.

Upload
Syntax
upload() : bool
A method that uploads the file.

Get Storage Directory
Syntax
getStorageDir() : string
This method is used to get the storage directory of the uploaded file. This is the directory that is stored in the database.

Delete
Syntax
delete(string $filename)
This method is used to delete a particular file from storage.

Preloaded Upload Types
Image Types
Syntax
ImageTypes() : array
This method returns an array of image file types.

Video Types
Syntax
VideoTypes() : array
This method returns an array of video file types.

Audio Types
Syntax
AudioTypes() : array
This method returns an array of audio file types.

Archive Types
Syntax
ArchiveTypes() : array
This method returns an array of archive file types.

Document Types
Syntax
DocumentTypes() : array
This method returns an array of document file types.

Font Types
Syntax
FontTypes() : array
This method returns an array of font file types.

Text Types
Syntax
getAllFieldsFirstError() : array
This method returns an array of text file types.

Custom Providers
You can also create your own custom provider. To create a provider, visit `localhost/myapp/init.engine.php`, in the provider section enter the name of the provider class and press enter. The provider file would be created for you in the `providers/` directory.
To make use of the provider, import it into the required controller class or provider class with the `use` directive
Example
use Providers\MyNewProvider;