Home >Backend Development >PHP Tutorial >PHP api project open source
As a phper, I have never written any decent php stuff. Share the demo source code of an API. This demo accesses two databases at the same time
developed based on php5.5. There should be many unsupported areas in 5.3.
Refer to some mainstream mvc frameworks, then combine your own ideas and remove the v. No single entry file is used.
composer loads class files
monolog open source code
1. cache: Cache folder, which will cache database field data by default.
2. config: configuration folder.
3. controller: Although it is named controller, there are multiple entry files stored in it.
4. core: core code.
5. lang: Verification error message template.
6. model: model.
7. vendor: composer
Is not perfect
1. There is no character set filtering and anti-injection function. (As long as the field length is defined reasonably, the pdo driver has its own anti-injection function. The most important thing is that I accidentally understood this, so I didn’t write this. I hope I can write it after I understand it)
2. Only one pdo driver was written. (There are many ready-made interfaces on the Internet, which can be directly used after modification. They are much more perfect than those written by yourself.)
3. I haven’t built a complete logging system because I think the only ones used in development are errors and warnings. (I defined various exceptions to throw, receive them in the entry file, and then write logs. As follows)
<code><span>try</span> { <span>...</span> } catch (AppException $e) { <span>...</span> } catch (Exception $e) { <span>...</span> }</code>
4. There are many other functions that I haven’t considered or don’t know, or I just don’t understand them. I didn’t write it.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });No more nonsense, let’s go directly to the code. I made a lot of comments in the code:
http://pan.baidu.com/s/1sjV4cc1
The above introduces the open source PHP api project, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.