How to Use Maintenance Mode with composer in Laravel

in #utopian-io6 years ago (edited)

What Will I Learn ?


  • How to Use Maintenence Mode with composer in laravel

Requirements


  • Xampp 5.6.3
  • Laravel 5.4
  • Composer
  • Google Chrome

Difficulty


  • Basic

Preliminary


Laravel is a PHP framework released under the MIT license, built with the concept of MVC (view controller model). Laravel is an MVP-based website development written in PHP designed to improve software quality by reducing initial development costs and maintenance costs, and to improve the work experience with applications by providing expressive, clear and time-saving syntax

Maintenance is an activity performed repeatedly with the aim that the equipment always has the same conditions with the initial state. Maintenance is also done to keep the equipment in a condition that is acceptable to the user.Maintenance is usually done to fix the wrong thing in a website and during maintenance we have to block all the data access into the website and give information to reader so that they can understand what is our being done. from tutorial you will learn block access to the website so you can make improvements with more focus. and this can also avoid the entry of other bugs from the outside before the previous bug successfully fixed.

Practice Maintenance Mode


In the repair of a website this technique will be very useful. and I will pursue it using the laravel framework. i will teach you how to turn it off and how to turn it back on and also how to improve the look of maintenance.

Step 1 :Turn on Server from shell xampp

You have to go into your laravel folder from shell xampp and use this command

php artisan serve

below is looked from xampp shell :

image

this command can be used also if you do not install apache because this use to run the server and this also you can run if you already have laravel stored in your computer. apart from the xampp shell you can also run it in the command prompt

Now open your browser and then type at address bar localhost:8000 and here the look server after running
laravel 1.JPG

Step 2 :Turn on Maintenance from shell xampp

Now we try maintenance mode because server have running. open other shell xampp .to do maintenance mode you can just use this one command:

php artisan down

below is looked from xampp shell :
image

Now open your browser and then type at address bar localhost:8000 and here the look server after
Maintenence

Capture.JPG

Now we will try to change text Be right Back to be text Maintenance so you can open file 503.blade.php from folder vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\views

This is script for maintenance mode:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Service Unavailable</title>

        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

        <style>
            html, body {
                background-color: #fff;
                color: #636b6f;
                font-family: 'Raleway', sans-serif;
                font-weight: 100;
                height: 100vh;
                margin: 0;
            }

            .full-height {
                height: 100vh;
            }

            .flex-center {
                align-items: center;
                display: flex;
                justify-content: center;
            }

            .position-ref {
                position: relative;
            }

            .content {
                text-align: center;
            }

            .title {
                font-size: 84px;
            }
        </style>
    </head>
    <body>
        <div class="flex-center position-ref full-height">
            <div class="content">
                <div class="title">
                    Be right back.
                </div>
            </div>
        </div>
    </body>
</html>

but you only need focus on this script . because we only change text Be Right Back. but if you change color and position or you wan add image . you can edit style from script above.

 <body>
        <div class="flex-center position-ref full-height">
            <div class="content">
                <div class="title">
                    Be right back.
                </div>
            </div>
        </div>
    </body>

Here's a little explanation :

  • class="flex-center position-ref full-height" this is a class used to call css style with the name is flex-center , ref-position, and full-height.
  • class="content" this is a class used to call css style with name is content .
  • class="title" this is a class used to call css style with name is title.
  • Be right back is text who show in the website

now change script above to be as below:

        <div class="flex-center position-ref full-height">
            <div class="content">
                <div class="title">
                    Maintenance 
                </div>
            </div>
        </div>
    </body>

and now you can trying open your browser and then type at address bar localhost:8000 and here the look after change.

image

Step 3 :Turn off Maintenance from shell xampp

Now we try exit from maintenance mode.so people can go back to your website. open other command prompt and type command

php artisan up

below is looked from xampp shell :
image

Now open your browser and then type at address bar localhost:8000 and here the look server after
live and maintenance finish.
laravel 1.JPG

this is one of the advantages in laravel. you can do maintance mode without having to make it again. You just need to use the commands in php artisan. for the next tutorial I will discuss about rollback and dropping with migration in laravel that I have not had time to share before

Conclusion


  • php artisan serve is the command used to run the server
  • php artisan down is the command used to enable maintenance mode
  • php artisan up is the command used to disable the maintenance mode

Curriculum




Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @iwaydi I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.029
BTC 56087.39
ETH 2965.10
USDT 1.00
SBD 2.15