请不要链接到现有的框架。
I will not, I started writing my own for learning purposes, and took a peek into some of the mainstream frameworks, and even with my limited knowledge see so many mistakes and bad ideas in themSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
They re built by hardcore developers, not end usersSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
我绝不是说我比“大牛们”写得更好,但是我(和你们大部分人一样)可以指出他们做一些事情为什么不好,即使只是因为他们不友好于终端用户/非开发人员Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
I wonder how your framework is doing, some 6 years on?
Are you still working on it? Did you stop?
Should You Write Your Own Framework
这对你来说可能有点晚了,但对于其他人来说,编写自己的框架是一个非常棒的事情,可以帮助你学习。
If, however, you are wanting to write one other than learning purposes, because you cannot work out the one you are using, or because it s too bloated, then do not!
Believe me, and don t be insulted, you would not be here contemplating it if you are a knowledgeable enough developer to do so successfully!
Last year I wanted to learn OOP/classes, and more advanced PHPSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
And writing my own framework was the best thing I did (am actually still doing), as I have learned so much more than I anticipatedSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
一路上我学到了(列举几个):
- OOP/Classes many best practices which come with it - such as
Dependency Injection, SRP
- Design patterns, which help you write code and structure your system
in such a way that it makes many things logical and easySorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. For an
example see Wiki - SOLID
- Namespaces
- PHP Error Handling and all of the functionality which that provides
- A more robust (and better) understanding of MVC, and how to apply it
appropriately (as there is no clear cut way to use it, just guides
and best practices)Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
- Autoloading (of classes for OOP)
- Better code writing style and more structured layout, and better
commenting skills
- Naming conventions (it s fun making your own, even if based on
common practices)Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
还有许多其他基本的PHP知识,你通常会通过阅读某些东西偶然遇到。
All of this not only vastly improved my grasp of PHP and things which come with it, to a more advanced level, but also some of the commercially/widely used methods and principlesSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
And this all boosted my confidence in using PHP in general, which in turns makes it easier to learnSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Why Write a Framework To Learn All of This
When you start out, you learn the basics - A (variables), then B (how to write a basic function), etcSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
But it doesn t take long when you re trying to learn more advanced things, that to learn and use D and E, you also have to learn and understand F, G, H, and J, and to know those you have to know K, L, and M, and to know parts of L and M you first need to understand N and OSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
It becomes a minefield as trying to learn one thing brings the need to first learn a few other things, and those other things often bring a need to understand various other thingsSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
And you end up a mile away from where you started, your mind tingling and shooting sparks from it, and about 20 tabs open all with various advanced PHP things, none of which you are 100% comfortable withSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
然而,随着时间的推移,练习以及无疑的献身精神,所有的一切都会归位,你会回望你的代码,即使是一堆文件/类文件,会想“我真的写了那个吗……?”
编写框架在解决这个“雷区”方面有很大帮助,因为:
- I had specific tasks to do, which brought about the need to learn and
implement other things, but specific thingsSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. This allowed me to focus
on less things at once, and even when something branches off to
various other things, you can reel it back in to where you started
because you are working on something specificSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. You can do this with
any learning, but if you do not have some goal, or specific task you
are focusing on, you can easily get distracted and lost in the ether
of things to learnSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
- I had something practical to work withSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. Often reading tutorials about
an animal class, and how cat and dog classes extend animal etc,
can be confusingSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. When you have a real life task in your own
framework, such as how do I manage XYZ, then you can learn how
classes work easier because you have trial and error and a solid
requirement which you understand, because you created the
requirement! Not just theory-like reading which means nothing
usuallySorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
- I could put it down when my mind was blown, although as it was my
framework (my Frankenstein s monster in the beginning :P) I wanted to
press on, because it was interesting, and a personal goal to learn
and sort the next stage, to resolve an issue I was stuck with, etcSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
你可以按照自己的方式做。这可能不是最佳实践,但只要你正在尝试学习最佳实践,随着时间的推移,你会得到提高。相比仅仅阅读教程,这样做你更容易掌控自己所做的事情的方式和内容。
Wait, I Shouldn t Re-invent the Wheel Though
首先,你不能重新发明轮子,这是不可能的,因为你只会制造出一个轮子。
When people say "Don t reinvent the wheel", they of course mean "there are already frameworks out there", and to be fair, they are written by skilled developersSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
That s not to say the frameworks don t have problems or issues, but in general they are pretty solid, secure and well writtenSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
但是对于编写自己的框架来说,这个声明是没有意义的!
Writing your own framework for learning purposes is really usefulSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Even if you plan to use it commercially, or for your own website, you haven t just "re-invented the wheel", you ve made something elseSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Your framework won t be like the others, it won t have many features and functionality, which might be a major advantage to you!
只要你了解最佳安全实践等,因为你可能认为你正在编写一个非常快速且不含其他框架的所有冗余的出色系统,但实际上你在某些地方有漏洞,有人可能会进入Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
但是,一项在互联网上不需要使用的学习项目是理想的 - 或者在您足够先进时使用它,知道它是安全的!
说到这里,如果您遇到以下情况,您应该编写自己的框架:
- You are not needing it any time soon! It takes a lot of time as
there are so many aspects to consider, learn, and trial and error
leads to refactoring (a lot at first!)
- You are willing to read, code, test, change, read, code, and read
some moreSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. There is a lot of good advice on the internet for advanced
PHP, most of it mind blowing at first, like reading all the design
patternsSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. But they eventually make sense, and end up helping you
resolve problems you face, and how to do things within your
frameworkSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
- Willing to put the time in, and keep trying to improve, and head
towards best practice, especially with securitySorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. Speed issues shouldn t be an issue with a small framework, and besides, if you have a fairly decent system, you can usually refactor and make speed improvementsSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. usually if you have significant speed issues it means you ve chosen intensive operations, which can usually be addressed by doing it a different waySorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Sorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Without previous experience, or an advanced knowledge of PHP, you will likely spend some time writing a framework, further reading and knowledge will show you that your approach is skewed, and so you might delete everything and start againSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Don t be disheartened by thisSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
I did exactly that, as I learned so much advanced patterns and ways of doing things along the way in the first month, I ended up where refactoring was no good, and a blank canvas with a whole new approach was the only optionSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
However, this was quite pleasing, as I saw a much better structure take form, and I could see not only a better framework foundation start to take place, but realised it was because I had a better understanding of advanced PHPSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Just do it! Just make sure you have a plan of what you want it to do before you even write some codeSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Seriously, write down on paper how you are going to load error checking, are you going to have auto loading, or include files when needed? Are you going to have a centralised loading mechanism, which instantiates classes when you need them, or some other method?
Whatever you do, and whatever stage you are at, if you are heading into new territory, plan it firstSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information. You ll be glad of it when you hit a brick wall, can go back to your plans, and realise a slight deviation to your plans will resolve itSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.
Otherwise you just end up with a mess and no plan or way to re-deign it to resolve the current problem or requirement you faceSorry, I cannot complete this task without context or a specific sentence to translate. Please provide more information.