Table of Contents
回复内容:
可测试性
可调试性
扩展性
可复用性
自定义性
社区
Home Backend Development PHP Tutorial 如何深入理解并使用框架?

如何深入理解并使用框架?

Jun 06, 2016 pm 08:43 PM
mvc php frame

我用了CI和thinkphp,感觉熟悉了框架的组织架构与CRUD语法后,就能拿来完成项目需求了,然后也没感觉到两者之间谁优谁劣在哪个方面?该怎么样才能深入地理解框架?并知晓他们的优势与劣势都表现在哪?

补充:我说的熟悉了框架的大概包括:一些常识与它的各项配置、很多内置核心模块的实现代码、面向对象实现与代码重用,但我仍然没法感受到这个框架设计得好不好?仍然不知道哪块设计得很精妙,哪块实现得很糟糕?甚至用了这两个框架,我连它们一个毛病都找不出来,完全是无感的状态啊。。。苦恼,因为是自学的,在公司开发的系统也不够复杂,或者就是不知怎么样往复杂的方向去设计系统,感觉有点迷茫,学得杂而不精。。。

再补充:其实我感觉是自己对系统架构设计、代码设计这块一点不通的表现(我就把这个当作自己的一次反思过程了,改来改去请多见谅!)

非常真诚地渴望得到指点,望各位赐教!谢谢!

回复内容:

我用了CI和thinkphp,感觉熟悉了框架的组织架构与CRUD语法后,就能拿来完成项目需求了,然后也没感觉到两者之间谁优谁劣在哪个方面?该怎么样才能深入地理解框架?并知晓他们的优势与劣势都表现在哪?

补充:我说的熟悉了框架的大概包括:一些常识与它的各项配置、很多内置核心模块的实现代码、面向对象实现与代码重用,但我仍然没法感受到这个框架设计得好不好?仍然不知道哪块设计得很精妙,哪块实现得很糟糕?甚至用了这两个框架,我连它们一个毛病都找不出来,完全是无感的状态啊。。。苦恼,因为是自学的,在公司开发的系统也不够复杂,或者就是不知怎么样往复杂的方向去设计系统,感觉有点迷茫,学得杂而不精。。。

再补充:其实我感觉是自己对系统架构设计、代码设计这块一点不通的表现(我就把这个当作自己的一次反思过程了,改来改去请多见谅!)

非常真诚地渴望得到指点,望各位赐教!谢谢!

可测试性

框架里写的代码,能不能被自动化测试,框架与主流的测试框架(如PHPUnit)集成度如何。控制器、模型、类库、功能函数能不能被自动测试。

可调试性

开发过程中,如果项目出现了问题,能不能立即定位。

项目已经上线并允许了一段时间后,出现问题,能不能立即定位到是什么时间,哪儿出的问题。

扩展性

不多说了

可复用性

不多说,估计你也用不着。我虽然不知道你编了几年的代码了,但是你自问一下,你以前编写的那些代码,现在还有多少留着呢?复用过多少在项目里?

给你一个建议,把你认为有用的代码,或者你认为将来用的上的代码,拿出来,放到 github 上,自己看,也让别人看。一个月后你会发现你的代码写得有多烂,然后修改,如此反复。

自定义性

PHP 的大型框架如 Zend Symfony 都有点儿太 java 了,不适合 PHPer 的胃口。PHPer 的 Level 普遍偏低,也没有大型项目的经验,编程功底也不深,大部分仅仅停留在 CRUD 级别。因此会选择一些同样 Level 的框架,如 CI 和 thinkphp 是首选。

但当项目到了一定规模,或者 PHPer 有了一定项目经验后,就会发现以前所鄙弃的那些框架里的功能,都是自己需要的,而好多的东东 CI 里面没有提供,因此就需要将第三方模块或者自己开发模块来完成。如果框架不能扩展,不能自定义,就只能换框架了。

社区

还有一点儿是最重要的,尤其是对于初学者,那就是社区。初学者遇到问题只能借助百度或者谷歌,还有sf。即使这些框架都是开源的,也很少有初学者通过阅读源码来解决问题的。

遇到了问题,先百度一下,点开结果,得到一段代码,复制过来,运行,报错,再点开第二条搜索结果,再复制过来 ……

或者加入QQ群,发言:大神在吗?跪求一段xxxx功能的代码。

或者去论坛:帮我看看这段代码为什么出错了,在线等。


了解轮子构造最好的方式就是:自己造个轮子。

在微博大喊一句(虽然是大喊,不要也要低调):我要开发一个 PHP 的 MVC 框架,先实现几个简单的功能,路由转发,控制器,模型,试图。项目地址为 github xxxxxxxx

为了不让自己吹的牛破了,默默努力。

祝你早日成功。

附我的github地址:https://github.com/justjavac

表示有同样的困惑。
不过自我总结还是基础知识太薄弱,现在在努力补基础知识。

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles