[Laravel] architecture of the Laravel framework

Source: Internet
Author: User
Tags ruby on rails
[Laravel] Laravel Framework Architecture Laravel is called a "full-stack" framework because it can handle everything from network services to database management and HTML generation, the vertically integrated web development environment provides developers with a better experience.

Developers can use the command line tool to generate and manage the Laravel project environment. Laravel comes with an excellent command line tool named Artisan. It provides some useful commands during development and can be used to generate framework code and manage databases. It is developed based on the powerful Symfony Console component.

Laravel aims to create a pleasant development process for developers without sacrificing the functionality of the application. Happy developers can create the best code! For this purpose, we concentrate on Laravel, which is based on development languages or tools such as Ruby on Rails, ASP. net mvc, and Sinatra.

Laravel is easy to understand and powerful. It provides powerful tools for developing large-scale and robust applications. Outstanding IoC, database migration tools, and tightly integrated unit test support give you the ability to build any application.

Directory structure

This is where all laravel projects have basically the same directory structure and each file has a specified location. By specifying the directory structure, make sure that you work in the "laravel mode.

As you can see, the laravel project has four folders: app, bootstrap, public, and vendor. There are many subfolders under these four folders, when you see such a rich set of folder content for the first time, do you feel a lot of pressure? It doesn't matter. we will learn about different folders one by one.

  • The app contains the controllers, models, views, and assets of the site ). These are the main code for running the website. you will spend most of your time in this directory.
  • Bootstrap is used to store the files required for system startup. these files will be called by files such as index. php.
  • Bootstrap is used to store the files required for system startup. these files will be called by files such as index. php.
  • The public folder is the only Directory of the web server that can be viewed from outside. It contains the index. php boot file at the core of the laravel framework. this directory can also be used to store any publicly available static resources, such as css, Javascript, and images.
  • Vender
  • App Directory

    Model-view-controller (MVC)

    This gives us a deeper understanding of how to build laravel applications. You may have noticed that the app directory contains three sub-directories: models, views, and controllers. This indicates that laravel is a model-view-controller (MVC) Architecture mode. it separates the "business logic" from the input and display logic (GUI) related to the graphic user interface. In laravel Web applications, business logic is usually composed of data models (such as users and blog posts), while GUI is just a page in a browser. The MVC design pattern is very popular in the Web development field. Three elements of the MVC pattern:

  • Model)
  • View)
  • Controller)
  • Laravel response process

    A typical laravel application consists of the MVC mentioned above.

    When accessing a laravel application, the browser sends a request, which is received by the Web server and transmitted to the routing engine of laravel. After the laravel router receives the request, it redirects the method to the corresponding controller class according to the configuration.

    Then the controller class takes over. In some cases, the controller will immediately render a View, which is a template that will be converted to HTML and sent back to the browser. For more common dynamic websites, controllers interact with models and communicate with databases. After the model is called, the controller presents the final view (HTML, CSS, and image) and returns the complete web page to the user's browser.

    Laravel advocates models, views, and controllers, and should maintain completely independent storage of separate files in different directories. This is where laravel's directory structure works.

    The creation of design patterns like MVC is to make the work of developers easier. This is where Laravel is better than PHP that does not use any mode. If this discussion is very abstract, don't worry! When you start working with Laravel, you don't even realize that you are working in a design pattern. After a while, it will become natural.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.