◆Secondary development
What is secondary development?
Secondary development, simply put, is to use existing software Make customized modifications, expand functions, and achieve the functions and effects you want. Generally speaking, the core of the original system will not be changed.
Why secondary development?
With the continuous development of information technology, a series of excellent open source works have emerged in the IT industry, and their authors or individuals , or a project team, or
is a software company. Selecting and applying these excellent open source software, and carrying out secondary development that meets business needs on this basis, will save enterprises informationization costs (time costs and development costs), and at the same time, it can also bring Technical guarantee. This is what we often hear: standing on the shoulders of giants, you will see further. Therefore, many domestic companies need secondary development talents.
How to do secondary development?
First, you must have a language foundation for the language used in this open source product. Being able to understand the code is the most basic.
Second, you need to be familiar with the functions and uses of this open source product. Only when you are familiar with it will you know what you want to change and what is the requirement. It comes with the system, how can I change it? Third, you must be familiar with the data structure, code structure, system framework structure of this open source product, what is the core, and where are the subsidiary functions.
To put it simply, it means familiarity with databases, code logic, and file directories.
Fourth, according to your needs, then use the core of the open source product to expand and modify the system to meet your needs. Introduce the basics of secondary development of PHP open source
products Requirements:
First, basic requirements: HTML (must be very familiar with it), PHP (can understand code and write some small systems, such as message boards, small CMS),
Mysql (know at least one database), Javascript (can understand it and can modify some existing codes), p+Css (can adjust the interface and understand how CSS
is used)
Second, be familiar with the use of open source products, such as Dedecms. You need to know how to log in, how to create a new column, how to add articles, how to use template tags, the concept and use of models, etc. Function
Third, you must be familiar with the database structure of this open source product, and understand the contents of the core files inside, such as: how to use the database class, how to perform commonly used security filtering , how to use the template engine and other core contents. You also need to know the directory structure of this open source product, that is to say, you need to know where the templates are placed, where the controls are placed, where the styles are placed, etc.
4. Familiarize yourself with your needs, interpret them, and then determine how to modify and expand this open source product
What can you get after secondary development?
You can fulfill your needs and you can accumulate experience. The experience here is your own and that of others. The so-called other people's is that when you do this second development, you can absorb the essence of this system and then integrate it into your own thinking, and you can also summarize the experience of the project architecture. There is a saying
that is good, that is: smart people will regard other people's failure experience as their own experience, while stupid people will take it as their own experience after experiencing countless failures.
ownexperience. Secondary development is not just development, but more importantly, absorbing the essence, summing up experience, straightening out ideas, avoiding detours, and improving oneself.
Standing on the shoulders of giants, you will see further!!! ◆DedeCMS secondary development
In order to let more people understand the secondary development and understand the secondary development of DedeCMS more conveniently, the following will briefly introduce some basics and outlines of the secondary development of DedeCMS
Necessary foundation for secondary development of DedeCMS:
· Very familiar with HTML · Familiar with the layout of p+CSS
· Solid PHP foundation, Familiar with structured programming, understand OOP, and be able to understand and use · Familiar with MYSQL, master the SQL language
DedeCMS secondary development learning process
· Understand what CMS is · Be familiar with the functions of DedeCMS (such as column classification, document management, use of models, system settings and other common functions)
· Master the templates of DedeCMS Tag usage and principles
· DedeCMS directory structure analysis
Familiar with what files are mainly installed in each folder, so that you know what files in which folder to modify during secondary development
Directory structure summary:
./a Generated file storage path
./data Cache file and data center
/admin Manage background data
/backupdata backup data
/cache cache file
/enums level linkage data, JS, enumeration type cache file
/ js Commonly used JS /mark watermark related files
/module module installation file
/rss Rss related
/sessions Session storage path
/textdata text data
/tplcache template cache
/uploadtmp upload file cache location
/ziptmp zip package decompression cache location
……
DedeCMS file structure analysis
Familiar with the basic functions of each file, it is convenient to make modifications. After knowing the general function of each file, you can easily modify the files
File structure summary:
common.inc.php database configuration file
config.cache.bak.php background system configuration backup
config.cache.inc.php Backend system configuration file cache
downmix.data.php collection obfuscated cache file
mysql_error_track.inc MYSQL error log
safequestions.php Security Questions
Sitemap.html Site Map
sys_pay.cache.php Payment Gateway Configuration
Template.rand.php Random Template Settings
……
· DedeCMS database structure analysis, at least be familiar with the role of each table
Familiar with the role of each table, understand the design of several core tables and the meaning of the fields, so that it is convenient to obtain After new requirements are met, you can quickly determine whether to add a
segment or create a new table for processing. At the same time, you can also understand the database design ideas of DedeCMS and add useful design ideas to your own system.
·DedeCMS process control and analysis of some core files
Familiar with some common process controls such as login, registration, document management, permission control, classification management, model setting, etc.
Dissect several core files to understand their programming skills and security mechanisms
· Development of DedeCMS plug-ins (**** plug-ins and embedded plug-ins)
Familiar with the writing of two plug-ins, the import and export of plug-ins, and the use of plug-in matching models
◆Ecshop secondary development
EcShop secondary development learning Method
In recent years, with the development of the Internet, e-commerce has also grown along with it, and B2B, C2C, and B2C e-commerce models have also continued to mature. At this time
spawned many e-commerce related PHP open source products. In terms of B2C, there are well-known products at home and abroad such as Ecshop, Zencart, Magento, etc.
Let’s briefly introduce the process of learning Ecshop secondary development and some things to pay attention to:
The necessary foundation for Ecshop secondary development:
· Very familiar with HTML
· Familiar with the layout of p+CSS
· Solid PHP foundation, familiar with structured programming, understanding of OOP, and able to understand and use
· Familiar with Smarty template engine
· Familiar with MYSQL and master the SQL language
· Ecshop secondary development learning process
· Familiar with the basic concepts of e-commerce
· Be familiar with the basic functions of EcShop (product types, product classifications, product attribute settings, use of promotional activities, etc.)
· Master the database structure and database design ideas of Ecshop
· Familiar with the ER model, the establishment of entities and relationships
Familiar with the role of each table, the design of several core tables and the meaning of the fields, so that you can quickly judge whether to obtain new requirements. Add the
paragraph or create a new table for processing. At the same time, you can also understand Ecshop’s database design ideas and add useful design ideas to your own system
· File structure analysis and code analysis
Familiar with some login, registration, document management, and permissions Control, classification management, commodity type and other common process controls.
Dissect several core files to understand their programming skills and security mechanisms
· Ecshop file structure analysis:
\includes\cls_captcha.php: Verification code image Class
\includes\cls_ecshop.php: Basic class
\includes\cls_ecshop.php(56): Password compilation method;
\includes\cls_rss.php: RSS Class
\includes\cls_smtp.php: SMTP mail class
\includes\inc_constant.php: Constant
\includes\init.php: Frontend common file
\includes\lib_common.php: Common function library
\includes\lib_goodscat.php: Front-end common function library
\includes\lib_insert.php: Dynamic content function library
\includes\lib_main.php: Front-end public function library
\includes\lib_payment.php: Payment interface function library
\includes\iconv\cls_iconv.php: Character set conversion class
\includes\ip\cls_ip.php: IP location query class
\includes\modules\integrates\discuz.php: Member data processing class
\includes\ modules\integrates\ecshop.php: Member data processing class
Ecshop template replacement
Familiar with the use of the streamlined version of Smarty, embedding your own interface, EcShop template replacement skills
Ecshop secondary development example
The function of switching between Chinese and English, the flash sale function, the production of JD.com templates, etc.
Learning objectives:
1 , Will use Ecshop for secondary development
2. Will change ordinary templates and modify some functions
3. Learn from the development experience inside
Master the basic knowledge-》 Imitate some of the writing methods inside-》Modify the patterns inside (form your own development model)
Master the programming skills and system design skills in Ecshop
◆Caching technology analysis
Analysis of common PHP caching technology [Conceptual version]
In most cases our website will use a database as a container for site data storage. When you execute a SQL query, the typical process is: connect to the database -> prepare the SQL query - > send the query to the database - > get the results returned by the database - > close the database connection. However, some data in the database
is completely static or changes infrequently. The caching system will cache the results of the SQL query to a faster storage system to store
. Avoiding frequent database operations greatly improves program execution time, and caching query results also allows you to process them later.
Commonly used caching technology
Data cache: The data cache mentioned here refers to the database query cache. Every time a page is accessed, the corresponding cached data will be first detected
Exists, if not, connect to the database, obtain the data, and serialize the query results and save them to the file
. In the future, the same query results will be obtained directly from the cache file.
Page cache:
Every time you access a page, it will first check whether the corresponding cached page file exists. If it does not exist, connect to the database and get the data,
Display the page and generate a cached page file at the same time, so that the page file will be effective the next time you visit. (Template engines and some common cache classes on the Internet usually have this function)
Memory cache:
I won’t introduce it here. It is not what this article will discuss. A brief mention:
Memcached is a high-performance, distributed memory object caching system used to reduce database load and improve access speed in dynamic applications.
Dbcached is a distributed key-value database memory cache system based on Memcached and NMDB.
Although the above caching technology can well solve the problem of frequent database queries, its shortcoming is that the data is not timely. Here I give the methods I commonly use in
projects:
Time triggered cache:
Check whether the file exists and the timestamp is less than the set expiration time. If the file modification timestamp is less than the current timestamp minus the expiration timestamp
If it is large, then use the cache, otherwise update the cache.
Don’t judge whether the data needs to be updated within the set time, and update the cache after the set time. The above is only suitable for use
when the timeliness requirements are not high, otherwise please see below.
Content-triggered caching:
When data is inserted or updated, the cache is forced to be updated.
Here we can see that when a large amount of data needs to be updated frequently, disk read and write operations will eventually be involved. How to solve it? In my daily
projects, I usually do not cache all the content, but cache some content that does not change frequently to solve the problem. But in the case of heavy load, it is best to use shared
memory as a cache system.
At this point, PHP caching may be a solution, but its disadvantage is that because each request still needs to be parsed by PHP, under heavy load, the efficiency problem is still more serious than the efficiency problem. , in which case static caching may be used.
Static cache
The static cache mentioned here refers to HTML cache. HTML cache generally does not need to determine whether the data needs to be updated, because it is usually used in places where HTML is used
Generally, pages that do not change content frequently. When the data is updated, just force the HTML to be updated.
In fact, a caching system involves many problems. I will only introduce my usual caching ideas here, and I will not introduce the use of software to
implement caching and write specific codes.
If you have any good solutions, please submit them below and let us discuss them together.
◆PHP uses function calling commandsPHP uses functions such as exec and system to call system commands
PHP’s built-in functions exec and system can be used Call system commands (shell commands), and of course passthru, escapeshellcmd and other functions. In many cases, using PHP's exec, system and other functions to call system commands can help us complete our work better and faster. For example, exec helped me a lot when I was batch processing .rar files two days ago.
Today I will sort out the commonly used calling system functions and share my experience with everyone.
Note: If you want to use these two functions, the safe mode in php.ini must be turned off, otherwise for the sake of security, PHP will not allow you to call the system command
.
First, let’s take a look at the explanation of these two functions in the PHP manual:
exec --- Execute external programs
Syntax: string exec ( string command [, array &output [ , int &return_var]] )
Explanation:
exec() executes the given command command, but it does not output anything, it simply returns the last line from the result of the command ,like
If you need to execute a command and obtain all data from the command, you can use the passthru() function.
If the parameter array is given, the specified array will be filled with each line output by the command. Note: If the array previously contains some
elements, exec() It will be appended to the end of the array. If you don't want this function to append elements, you can call unset() before passing the array to
exec().
If the parameters array and return_var are given, the status command returned to execution will be written to this variable.
Note: If you allow data from user input to be passed to this function, then you should use escapeshellcmd() to ensure that
this user cannot trick the system into executing Arbitrary order.
Note: If you use this function to start a program and want to leave it while it is executing in the background, you must make sure
that the output of the program is redirected ) to a file or some output data stream, otherwise PHP will hang until the program execution
ends.
System --- Execute the external program and display the output
Syntax: string system ( string command [, int &return_var] )
Description:
system ( ) Execute the given command command and output the result. If the parameter return_var is given, the status code of the executed command will be
written to this variable.
Note: If you allow data from user input to be passed to this function, then you should use escapeshellcmd() to ensure that
this user cannot trick the system into executing Arbitrary order.
Note: If you use this function to start a program and want to leave it while it is executing in the background, you must make sure
that the output of the program is redirected ) to a file or some output data stream, otherwise PHP will hang until the program execution
ends.
If PHP is running as a server module, system() will try to automatically clear the web server's output buffer after outputting each line.
Returns the last line of the command if successful, false if failed.
If you need to execute a command and obtain all data from the command, you can use the passthru() function.
Both of these are used to call system shell commands,
The difference is:
exec can return all execution results to the $output function (array), $status is the status of execution, 0 is success, 1 is failure
Systerm does not need to provide the $output function, it returns the result directly, similarly $return_var is the status code of execution, 0 is success, 1
为FAILURE
◆About open source
The biggest success of open source comes from the Web
The open source movement is widely popular and has written a strong mark in the history of software development. But where is its most far-reaching impact? What is the most
successful open source "project" in history?
In fact, overall, isn't the Web an open source movement? The biggest success?
Perhaps the most famous example is LAMP behind many websites in hidden domains, which is Linux, Apache, MySQL and PHP. But when you think about it
, you'll find more.
Listed below are some open source projects that enable the Web to run.
Web browsers-Web browser
In the web browser market, although Microsoft's closed source software IE browser still occupies a large share, other open source projects with similar functions
has become popular and continues to grow. Like Mozilla's Firefox browser (it is open source, as well as Flock and PaleMoon). There are also rapidly growing Webkit-based browsers, like Safari, but the most famous is Chrome.
If you include mobile networks, Webkit dominates the browsers in iPhone, Android and Blackberry phones.
Web server software-Web server software
So far, Apache is the most widely used network server software. It is open source, but a lightweight server software called Nginx
pieces have become popular in recent years. In fact, two of the three top web server software are open source (the exception is Microsoft's IIS, which ranks second, but it is far from first).
In addition, a large number of server-side underlying software are also open source. For example, many high-traffic websites use Varnish as the caching layer with website visitors, and use Memcached as the caching layer with the website database. These are just two of many examples.
Scripting languages and web frameworks-Scripting languages and Web frameworks
Most of the programming and scripting languages used on the Internet are open source, such as PHP, Perl, Python, Ruby, etc.
However, few websites are completely built from scratch. It is no exaggeration to say that there are hundreds of open source content management systems (CMS) and web frameworks to assist developers, such as WordPress, Drupal, Ruby on Rails, Django, Joomla, DedeCMS, Ecshop, etc. .
Databases-database
The open source software MySQL is by far the most popular website database, but there are other open source software with similar functions, such as PostgreSQL, not to mention the many "non-relational (NoSQL)" that have appeared recently. database.
Since we are talking about the underlying software, we have to mention the basic
system that we rely on every time we use the Internet or anything on the Internet:
DNS-Domain Name Resolution System
The Web (for that matter, the entire Internet) is nothing without the domain name resolution system. As we all know, the domain name resolution system allows users to use domain names like example.com instead of IP addresses. BIND is pretty much the de facto standard for DNS server (aka name server) software, and, as you've probably guessed by now, it's open source.
Server operating systems-Server operating systems
All websites must run on servers, and that is where open source reigns. Although Windows dominates the desktop space, most of the servers that websites run on use the open source Linux operating system. Other popular choices are freeBSD and OpenBSD.
The temptation of open source
Because in many cases, open source software can provide the same performance as commercial closed source software and is free, so open source software
It's no surprise that it's so popular. Free is a hard price to beat.
If the Web didn't run on all this free software, it would probably have a hard time gaining widespread acceptance.
Note that we did not say that there is no closed source software on the Web, but that obviously exists. However, from a statistical point of view, the real exception in the field of Web open source dominance is Microsoft's Windows-based series of systems.
Beyond that, you usually have to dig deeper to find more proprietary closed source technologies, like the operating systems on routers and similar devices. But that
is the Internet, not the Web.
The above is the detailed content of A detailed introduction to the best secondary development of cms. For more information, please follow other related articles on the PHP Chinese website!