It might be intimidating to dig into the source code of a framework. This chapter is here to guide you. Hopefully, there’s not too many components in Minz so we’ll soon have covered it all.
Note that I only make quick presentations here. You’ll have to read the code and the comments to learn how to use these classes.
I have highlighted the classes that I believe are the most important of Minz. You’ll often have to interact with them.
\Minz\Configuration
loads and stores your configuration;\Minz\Dotenv
is often used in configuration files, to load environment variables;
\Minz\Request
abstracts HTTP or CLI requests;\Minz\Response
abstracts HTTP or CLI responses, it embeds a\Minz\Output
(interface) which is in charge of rendering the content. Here is the list of available outputs:\Minz\Output\View
is a simple template system to render your content, often used for (but not limited to) HTML;\Minz\Output\Text
renders text;\Minz\Output\File
renders files;
\Minz\Router
is in charge of the routing of your application;\Minz\Url
renders the URLs of your application, using the information from the router;\Minz\Engine
does the plumbing of your application, executing a controller action based on a given request and returning its response;
To learn how to use these classes, read the “getting started” guide.
\Minz\Database
abstracts the connection to the database, it acts as a wrapper around the PHP \PDO class.\Minz\Database\Recordable
provides useful methods to manipulate the models in the database. It is usable together with the following classes:\Minz\Database\Table
to define the database table of the model;\Minz\Database\Column
to define the database columns of the model;\Minz\Database\Factory
to easily create models with default values during the tests;\Minz\Database\Helper
which provides useful methods to the Recordable trait;\Minz\Database\Lockable
provides some methods to (un)lock a model;
\Minz\Validable
a trait to validate the models properties values. It is used alongside withCheck
s:\Minz\Validable\Check
the base class extended by the other classes;\Minz\Validable\Comparison
allows to compare the values;\Minz\Validable\Email
allows to check email addresses;\Minz\Validable\Format
allows to check the format of a string;\Minz\Validable\Inclusion
allows to check that a value is included in a given set;\Minz\Validable\Length
allows to check the min and/or max length of a string;\Minz\Validable\Presence
allows to check that a property is present (not null nor an empty string);\Minz\Validable\Url
allows to check URL addresses.
\Minz\Form
provides an easy way to handle forms. It is used alongside with:\Minz\Form\Field
to declare fields in the forms;\Minz\Form\Csrf
to protect against CSRF attacks in the forms;\Minz\Form\Check
to declare custom checks in the forms;
\Minz\Log
logs errors and information to syslog;\Minz\Job
to manage asynchronous jobs, it is used with\Minz\Job\Controller
;\Minz\Migration\Migrator
manages the migrations of your data, it is used with\Minz\Migration\Controller
;\Minz\Controller\ErrorHandler
allows to execute code on errors triggered in controllers;\Minz\Csrf
protects you from Cross-Site Request Forgery attacks;\Minz\Email
is an utility class to sanitize and validate emails;\Minz\Flash
to pass messages from a page to another through redirections;\Minz\Random
to generate random values;\Minz\Time
abstracts the time;\Minz\Mailer
is a wrapper around PHPMailer to send emails;\Minz\File
abstracts uploaded files;\Minz\Translatable
to mark aValidable
message to be translated.
The three last classes are very useful during tests!
Finally, Minz provides a bunch of helpers and assertions for PHPUnit:
\Minz\Tests\ApplicationHelper
allows you to execute a request against your application and get its response in a single line of code;\Minz\Tests\InitializerHelper
reinitializes the database, session and mailer before each tests;\Minz\Tests\ResponseAsserts
provides a bunch of assertions to test the response of your application;\Minz\Tests\TimeHelper
freezes the time, on the condition that you use the Time class;\Minz\Tests\Mailer
catches emails sent by the mailer and allows you to test them with the assertions provided by\Minz\Tests\MailerAsserts
;\Minz\Tests\FilesHelper
provides a method to copy files in a temporary directory in order to simulate an upload to your application.