preface

Due to the separation of the front and back end development work, how is the back end function being designed at the present stage, and the front end UI is also being adjusted. It seems the project will not get started. Instead of creating your own data, try using mock tools for early development. I’ve tried mock. js and I don’t particularly like hard-coded mocks. I’ve also worked with Express Server and it’s not quite what I wanted. I tried to use PHP to write a small framework, with Faker, to achieve data simulation. In my opinion, this is the real separation, the front and back end middleware.

Prophase preparation

Change localhost,(C:\Windows\System32\drivers\etc\hosts) configure a virtual domain name to localhost. In the last line add:

127.0.0.1	milfun.com
Copy the code

Then modify the httpd-vhost.conf file in the Apache conf file to add the virtual domain name.

<VirtualHost *:80>
    DocumentRoot "D:\zend\Apache24\htdocs\MilFun"
    ServerName milfun.com
    <Directory "D:\zend\Apache24\htdocs\MilFun">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Copy the code

Framework development

Framework directory

Entrance to the file

The core function

Since it is middleware, I think it is good to be able to implement some basic functions – input and output

Basic framework: is very mature MVC structure, but here only C is good, because it is a simulation interface, as long as it can control the business jump. Clear business: so analyze the URL address and assign a route, jump to the corresponding PHP file, also need to be able to get the parameters in the URL,

Interface data: Returns Ajax data that conforms to the format.

Routing control

milfun.com/jobs/

The business process

The method in the figure above automatically returns the name, email, and address.

benefits

Instead of waiting for the back-end functionality to be developed and then calling the data interface, you can simply use simulated data. You can also use this project and the back end to agree on the format and parameters of the data to be returned. Just change the interface address. That’s real decoupling!

And then in the front end, instead of waiting for all the interfaces on the back end to be written,

Said in the last

This project is not open source yet, because everything has just started, there are too many shortcomings, only for their own use and optimization, if you really feel good, you can also get private, thank you for your support.