Home  >  Article  >  Backend Development  >  Cakephp 3.x (Preface-Why use frameworks)

Cakephp 3.x (Preface-Why use frameworks)

巴扎黑
巴扎黑Original
2016-11-09 11:50:441521browse

I took a Web Engineer course when I was a graduate student. The course at that time was java servlet + Tomcat + Mysql to develop a social networking site similar to Facebook. The teacher who gave the lecture mentioned the framework and said that the purpose of the framework is to reduce the time of early rotation. The cost of learning the framework is to read the Documentation, which usually takes a month to learn and explore. But I don’t think so. Building blocks with your bare hands is cool and awesome.

I really came into contact with the framework in early 2015, when I just started working. At that time, I used Cakephp, a framework I heard during my internship at NXP. Cake's early idea was to inherit RoR (Ruby on Rails) 100%, such as migration and command line. Of course, what is criticized is Cake's data encapsulation model, which favors relational databases. Although Cakephp may not be as well-known as Lavare, there are still many questions from the core developers, community activity, and Q&A community.

For those who are new to website building, Cakephp is very efficient in development and easy to expand. And for children who are inspired to become architects, I personally think the learning value of reading Cakephp core code is very high. In the early stage, through the use of the API encapsulated by Cakephp, you can understand the basic modules and functions of the ordinary MVC framework. In the process of advanced, read the core code to understand the design principles. Finally, by optimizing the code, it reaches the point of integration. As a fledgling phper, the author is also groping and working hard in development. I hope to provide my thoughts and ideas to everyone who can read this article and make progress together with you.

This series mainly focuses on translating Cakephp 3 Cookbook, focusing on the experience of using Cakephp 3 in the development project process, while interspersed with introducing the characteristics of Cakephp 3. I hope to make some small contributions to Cakephp by introducing and translating Cakephp 3. I also hope to meet like-minded friends through this series.

Before getting into the details, let’s quickly talk about some of the functions of Cakephp 3.

1). Naming Conventions
Cake, like RoR, Django and other frameworks, provides a complete set of MVC convention names. Using naming conventions, you can conveniently use some of the functions provided by Cake. It is also helpful for code maintenance after the project. For the development process, naming conventions contribute to development efficiency.

2). Data layer (Model)
Compared with Cakephp 2, the data layer of Cakephp 3 has been significantly improved. Not only does it support MYSQL, PostgreSQL, Microsoft SQL Server, SQLite, etc., but the ORM also provides two different data CRUD APIs. Users can use native SQL statements to call the database and process queries flexibly. The Entity processing class provides a set of encapsulated APIs that can be used to safely process data.

3). Views
The view layer provides basic data presentation. Templates and extension modules efficiently simplify code, making front-end code more concise and reusable. At the same time, the view layer provides a complete RESTFUL application, including XML, JSON and other resources, which can provide a web server for the website in the form of URI.

4). Control layer (Controllers)
As the core logic layer, the control layer effectively combines the data layer and the view layer. Important algorithm processing can be implemented and improved at this layer.

Cakephp 3.x (Preface-Why use frameworks)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn