December 23, sponsored by the Open Source China Institute of Electronic Technology Standardization, the 2017 year-end ceremony held in Beijing Marriott Hotel successfully. At this conference, the vice President of chain group Technology, the core member of the PHP Development Group, gave a speech on the topic "PHP Next:jit", sharing the main steps of PHP's next performance improvement: the progress of JIT, and the possible features of the next big version of PHP. For details, see: Https://mp.weixin.qq.com/s/bYZLJgKtdRwSX40Xixc5Yw, PHP Next is currently under development, led by Zend's Dmitry stogov, but the actual version number has not yet been defined, I'll call it PHP 8 for the moment. Critical function JIT (just-in-time) compilation is a technique for translating code into another bytecode, such as the local code that runs its machine CPU. JIT can make programs run faster. The JIT can provide significant performance improvements to existing code, but in some cases you may notice that the speed increase is only a few percent, and in the worst case, it may even slow down because the compilation does not generate faster code. I saw the content of this article and I remembered it. NET platform for open source projects Peachpie.
The
Peachpie is a PHP compiler and runtime for use on the. NET platform. Fully re-implemented as a PHP language, it allows you to write completely using. NET and run PHP on the. NET Framework, net Core, and Mono. Peachpie can seamlessly leverage. NET objects, and on the other hand, you can have C # code directly access compiled PHP functions, variables, and classes. The goal of the Peachpie project is to migrate the PHP code base to. NET, which provides the. NET and ASP. The latest version is 0.8, support for. NET Standard 2.0:https://www.peachpie.io/2017/11/php-netstandard-2-0.html, Peachpie is also in PHP 7.2 The first time the release was completed support for compiling PHP7.2 code to. NET https://www.peachpie.io/2017/12/php-7-2-on-net.html. Peachpie is now still a project under the. NET Foundation, which can be seen in blogs https://www.peachpie.io/2017/07/ Net-foundation-announcement.html, currently the latest version is 0.8, has not yet reached the 1.0 version running in the production environment, from his roadmap https://github.com/peachpiecompiler/ Peachpie/wiki/peachpie-roadmap is very close to the view. Its performance indicators are also very good https://www.peachpie.io/benchmarks
Peachpie is a modern PHP compiler based on Microsoft Roslyn and is available from our popular * * * phalanger * * Project. It allows PHP to run within the. NET Framework, opening the door to. NET for PHP developers-and vice versa. The goal of the project is to compile legacy PHP code into a portable class library that enables developers to quickly and easily build cross-platform applications and libraries for the Microsoft platform. As a direct result, PHP applications powered by Peachpie will run on all devices and operating systems that are capable of running. Net. In addition to granting PHP programmers cross-platform development, Peachpie allows full compatibility with. NET , which makes it possible to develop hybrid applications, some of which are written in C # and partially in PHP. These sections are fully compatible and can be used in the. NET Framework to communicate seamlessly within the
With Peachpie, you can already run classic PHP programs on the. NET platform, such as Wordpress,codeigniter,drupal, MediaWiki, and so on. However, there is one bug to fix, see https://github.com/peachpiecompiler/peachpie/issues.
Here's a brief experience of using PHP to write. NET programs: 1. Install the. NET Core SDK
. NET core builds and authorizes your application. This is a common, cross-platform and secure code environment.
2, install Peachpie. NET Template
We have prepared a common project type for you. They hide all the complexities of the project file and come with code samples.
dotnet new-i peachpie.templates:: *
A total of three templates: Console, Web, and class library
3. Create a website
Now create the project, which will create all the files needed for the initial solution. The Website
directory will contain the root directory of your PHP Web site.
Continue editing the newly created Website/index.php
file.
dotnet New Peachpie-web-lang PHP
4. Run your project
Navigate to the Server
directory. This is the portal to the Web application and works as a bootstrap for the PHP site.
These commands restore all dependencies, compile the project, and start the Web server.
CD Server
dotnet Restoredotnet Run
Test your site
Open your favorite Web browser and enter the URL.
HTTP://localhost:5004
They have launched a commercial website for Peachpie http://www.peachpiestudio.com/, providing business services support for Peachpie's development, and you can find business tools and services on the Peachpie compiler platform, You can develop the code on Visual studio/visual Studio codes.
WordPress Example
Peachpie uses their WordPress version as an example of PHP compiled to. Net. Let's show how to run.
- Download Project from Https://github.com/iolevel/peachpie-wordpress
- Unzip the file to a folder
- Installing mysql,wordpress using MySQL Database
- To change the database connection settings in wp-config.php
- Open the command line and go to the folder where the WordPress project files are switched
- Run the following command:
dotnet Restore
CD app
Dotnet Run
- Wait a few minutes until the application compiles and starts
- Open http://localhost:5004 in your favorite Web browser
. NET Core has implemented PHP JIT, now PHP is a development language on. Net