php extension, an implementation of helloworld
php -v
PHP 5.5.9-1ubuntu4.7 (cli) (built: Mar 16 2015 20:47:39)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Configuration reference article: http://blog.csdn.net/niujiaming0819/article/details/8543028
This article also uses the steps in the reference article to implement the process on this machine
step 1. Download the php source code package. You can download it from the php official website. This time, the php5.6.8 version is used
step 2. Unzip the compressed package and enter the decompressed package (mysoft$ cd php-5.6.8/). Use the ls command to view the file directory in the source package and enter the ext folder (cd ext)

step 3. Establish an extension development framework ./ext_skel --extname=helloworld
Execute the above command to establish the framework for expansion development. You will find that there is an additional folder called helloworld under the ext folder, and some text is also output from the command line,
You will be prompted with the general steps to generate the extension.

step 4. Enter the root directory of the php source code and edit the file vim ext/helloworld/config.m4
Remove a few lines of comments in this file, which will be roughly between lines 16-19. The specific version may be different and then save the file (: wq)
step 5. Execute the command ./buildconf --force
in the php source code root directory
step 6. Compile the php program in the root directory of the php source code. Note that the command is ./configure --with-helloworld
The last error that occurred was not processed
step 7. Enter our extension directory helloworld and execute the command phpize (install phpize through sudo apt-get install php5-dev). At this time, your extension directory will generate many files that can be used Post compilation.
step 8.Compile our extension in the helloworld directory./configure --with-php-config=/usr/bin/php-config (use the php-config of your own environment) -- enable-helloworld
You can find the location of your php-config file through a command (find / -name php-config) as shown in the figure: My address is /usr/bin/php-config
step 9. Enter the extended helloworld directory, edit the file php_helloworld.h, and add the function PHP_FUNCTION(helloworldTest);
in the last linehelloworldTest can be changed to your favorite name, then save and exit
step 10. Open helloword.c with vim, implement our function in helloworld.c, then add the helloworldTest function to helloworld_functions[], save and exit
step 11.Execute the make command to compile the extension. I ran it relatively smoothly. If an error occurs, please carefully check the previous steps to see if there are any errors. I also made errors when I did it for the first time. Generally, there is a problem with the previous steps.
step12. Copy the compiled helloworld.so file to your local php extension directory
The extension directory can be viewed through php -r phpinfo(); | grep extension_dir to view the extension path of native php
step 13. Configure php.ini to enable helloworld.so extension
View the location of php.ini (php -r phpinfo(); | grep php.ini )
vim opens the php.ini file sudo vim /etc/php5/cli/php.ini
Add extension (extension=helloworld.so) at the end of the file
Tested by php -r phpinfo(); | grep helloworld
step 14. Test extension (php -r echo helloworldTest();)
During this process, I tried following the original author’s steps, but an error occurred
Segmentation fault” (core dumped)
After debugging, the original author changed PHP_FE_END to {null,null,null} when adding it to helloworld_functions[] in the helloworld.c file. When he compiled it again, there was no error, but he also commented PHP_FE_END. Modification After that, just recompile and copy.

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools
