M
M
McMike2016-11-10 09:23:53
Yii
McMike, 2016-11-10 09:23:53

How to crawl into a script before execution starts in Yii2?

You need to block access to the site.
There is a sign in the database whether the site is active or not (it is being checked out from another place), and if not, you need to interrupt the script and display a message. Those. this must be done after loading the configs, check the entry in the database and close it. And this should happen on all pages.
Where can this be written? In some base controller?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-11-10
@McMike

You can implement this functionality using the application's bootstrap mechanism

A
Alexey, 2016-11-10
@masterfreelance

The catchAll route
Sometimes you may want to temporarily put your application into maintenance mode and display the same informational message for all requests. There are many options for accomplishing this task. But one of the simplest is to use the yii\web\Application::catchAll property , like so:

[
    // ...
    'catchAll' => ['site/offline'],
];

In this case, the site/offline action will process all incoming requests.
The catchAll property must take an array, the first element of which defines the route, and the remaining elements (key-value pairs) define the parameters to be passed to the action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question