 Jacob, you are still with us, right? And we're going to go ahead and zoom in. I'm going to figure out how to do this stream deck. Jacob, boom, we're going to zoom in. Where are we zooming to today? I never know where everyone's at. They're all over the world. Where are you at, Jacob? You're in Prague? Oh my goodness, what a beautiful, beautiful city. It's like 11 AM, so I'm fine. I don't know how you are, but I'm pretty good. Well, take it away, it's all you. I'll see everyone later. Today I'm going to show you the pitchpy compiler and some advanced interoperability features. So features on how you can integrate C-sharp or any kind of .NET project with a PHP, which is pretty cool and gives you a lot of options on how you can improve or extend existing PHP projects or extend existing C-sharp projects with a little bit of PHP. So let me start with a short introduction about pitchpy. It's like an entire platform. It contains a compiler, which is based on Roslin. So there is an entire code analysis project that takes a bunch of PHP files and analyzes it and creates all the trees and semantic trees and outputs the DL file. There is an entire runtime that supports the compiled PHP programs. And there are also a bunch of libraries that simulates or re-implements all the PHP stuff, like all the PHP extensions and so on. So to make it a little bit more clear, and I promise this is the only animation we have in this presentation, the compiler takes all of the PHP code. It can be a really huge project, like I will show you after a few minutes. And it also references any assembly, any dotnet reference you can have and creates a dotnet standard assembly which is portable, managed, and also it's sourced less. You don't have the original PHP source code in the resulting DL file, which gives you a few more other options on how you can distribute your PHP applications, for example. Anyways, let's move on to the first demonstration to make it more clear. It's a simple console application. So let me switch to Visual Studio Code. And in here, I have an empty folder. And we'll create a single PHP file. Let's start with a single PHP file. And fill this with something really simple, like hello, hello, WorldHip. And what every dotnet project needs is a project file. You can create it manually. You can download templates, as I will show you later. In Visual Studio Code, we have a really small extension that adds a comp to the command path. Yes, it's this one, which will create a project file for it. There it is. And what we see is a PHP file and a project file containing anything we are used to from C sharp. The output type property, the target framework, is dotnet core app 2.0. Some description, which is not necessary. But there's for instance, we are compiling files. It's not a PHP, PHP files, all the files. And one addition, we refer to friends in the new get package containing core. So this is real. You actually don't need any PHP, any web server. All other stuff is downloaded automatically when you first comp the debugger project. So debugging, and you can see in the browser, debugging. And of course, you can see the dotnet debugger, which means one great advantage of the entire project. Because all the tooling, all the great tooling of the dotnet can be used for the PHP apps as well. And we will show several other toolings during the presentation, like with the diagnostics and so on. But for now, I would like to demonstrate the interoperability features. So if you write a really small piece of code, like a general hello world, some function, so we will see how it works. OK, S value, and write this, I don't know, the value. And come, do something. I lost my mouse. Good. OK, I think I've just lost my keyboard. Wait a minute. Can we have a second? Sorry, I just lost the keyboard. Anyways, let's write a simple hello world application in PHP, like, hi, running it in a usual way. And what's great about the project, as I showed you before, is, yes, you can debug the application as any other dotnet application. But you can also use all the dotnet stuff. You can, implicitly, you get all the references to all the dotnet standard runtime and packages and anything you specify in your project file as a package reference or as a project reference or any other reference to a DL file. So I can write something without any other configuration, something like maybe system data type. And using the PHP syntax, I can print, I get the current time, convert it to string, and tonight using the PHP syntax. And run the project by, I think, a five and just continue. And you'll see it's seamlessly integrated with all the dotnet goodies. So what's the result of this compilation? As you are used to from any other C-sharp project, there is the bin folder with debug and net core app, and there is a DL file and PDB file for debugging features. And we can look at the DL file using some decompiler, like IOSpy, for example. So if we open the DL file and IOSpy like this, you'll see there's a bunch of weird methods. It's because they are meant to not be accessible. But there's also the function we've written. And you can see in the IOSpy, there's a regular call to the datetime function. So it's seamlessly integrated with no overhead at all. So you can write these C-sharp PHP hybrids like all together without any overhead. There's also a bunch of other runtime stuff that are generated by compiler. But everything works as one, as any other dotnet language. So let me, let's just for a quick info. Let me show you some more interesting topic, web application. In here, we can create a regular PHP web application, PHP website, without having a web server or having a PHP on your machine because we have sp.net core, and it's built in Caster web server. So we can create a C-sharp project that will target PHP and run its own web server. It can run on command line, on IOS Express, or IOS on Azure, or anything you are used to. So we start with an empty folder again. And for this purpose, we have prepared a set of templates. If it browse to our project website, there's already prepared command for it. So using this command.net new dash I, PHP templates, we can install dotnet templates to your dotnet installation. So if you run the command, it will download new packages, our templates. And there's one template that creates an ASP.net core website with some PHP already. So dotnet new web, but the language is PHP. You can write it like that. And you'll see it creates two projects, a server and a website. Website is a PHP project with the project file we've shown before. And the server is a regular, regular Caster web server hosting our project. We configure some sessions. We configure anything needed for running the project. But there's one additional line, which gives you the option to take all the scripts from the compile.io file and run it as a part of the ASP.net core pipeline. So we built the project for the first time. We download all the dependencies. So these warnings will disappear and you can put a breakpoint into the PHP code. And we can check some more advanced interoperability features we can make use with the pitchpoint project. I can hear it's working. So we can start a project as usual. Run it using the .net core configuration. Wine. I don't want to launch a browser. Let's run the project. And it runs on port 5.04. So ASP.net core started, initialized the pipeline and requested our request handler as part of the runtime of the pitchpy and passed the request to the compiled PHP file. And now we can debug the PHP file as we showed before. Continue and you see on your ASP.net core server a message from PHP code. Let's make it more interesting. We can, for example, create a class. But we can create a class in a C-sharp project. Let's imagine we have already some C-sharp library or let's call it class, library one. Create an initial project in here using .net new how we call class slip, I guess. So let's have a C-sharp project with a class. And what we can do now, we can reference this C-sharp project from a PHP project. So we can add regular project reference from the website, which is PHP project, to the C-sharp project. That's its class, library one, come on, one slash CSProm. And why would I do that? It's because I can use this .net classes in my PHP file. So in this way, imagine you have a huge PHP code consisting of thousands and thousands of files, which is not unusual. You can slowly replace them. You can slowly replace PHP classes with .net classes. For example, you are migrating your PHP project to .net. And you would like to gain some performance. So you just remove the class from PHP project and rewrite it in C-sharp. And the PHP code will look the same. So if we have a constructor, for example, in C-sharp, and I create in PHP class, library one slash, I guess it's called class one, class one, we can instantiate the objects as before without any difference. But the class was rewritten in C-sharp. So in this way, we can keep the old PHP code and slowly rewrite pieces of it into C-sharp. And if you run the project, let's make it more interesting. Let's make a function, for example. So foo, yellow from C-sharp, nice. And foo. And if you run the project, it will seamlessly integrate with .net, with my .net project. Where is it? So I'm here. Oh, it's running. So if you request a page again, the breakpoint hits our creation of the .net project. OK, I see. Well, you kind of know. I didn't recompile the project. One, there's missing. That's why. Let's run it again. And let's put some breakpoints so we see something is happening. Now we are on PHP. And it seamlessly stepped into the C-sharp. So if we take a closer look on the call stack, we are on one stack frame, we are on PHP, and then we are in C-sharp with no overhead at all. And the same with calling the function foo. But integration gives us more features, like all the types are converted with PHP and C-sharp, as you would expect. So if we have something like no other type in C-sharp, E, let's call it I, and we pass now, for example, in PHP, it gets automatically converted. But we can go one more step further. Because thanks to the integration and thanks to the interoperative features, we can extend C-sharp classes in PHP. And also PHP class is in C-sharp. So if you write something like my class, which extends this C-sharp class, it would all work and also with function overriding and anything you would expect. And also, we can write more integration features and make use of all the dotnet features you like, for example, but you don't have in PHP. For example, in PHP, they don't have delegates. They don't have an option how to wrap something in something as a delegate. They don't have type for it. They have something like closure or classes that have magic methods, like underscore invoke or underscore call. But in C-sharp, we are used to write delegates. So if I would have something like a function that will return a delegate, taking in and returning string, what to do, for example. And it will return this function doing something like converting the number to string in this notation. And it's fully typed. That's the reason why would I do it. PHP doesn't have fully typed anonymous methods, but C-sharp does. And I would prefer to have my code fully typed. So that's why I would write it in C-sharp instead. And now you can do the same in PHP. You can take your what-to-do method. And you can just call it with 1, 2, 3. But now it's strongly typed. And you cannot do a mistake. So let's try it again. Now it's running. So if you refresh the page, we are in here in the calling of foo to write something. Now it asks my C-sharp method what to do. And I will return an anonymous strongly typed method to the PHP. And then I will call it from the PHP code. So all this integration, all this interpolated features works seamlessly. You don't have to do anything. You just write the code as you would expect it. And you can treat the PHP code as you are used to. So I wanted to show you all this because we want to show you something bigger, something in the real Visual Studio, for example. And we need a few more things. We need to realize there is a bunch of libraries and bunch of runtime stuff in the PHP project. So there's a lot of features implemented in the project already. And also, we have to realize that the PHP code behaves like any other C-sharp project. So we can do things, for example, since you have this class in the website project, we would like to share it with others. And it is a good experience. It is a good to wrap your libraries into NuGet packages. So once we have this class in here, we can do things like .NET Pack. Yeah, it doesn't have a version. And it creates, as expected, a NuGet package containing your PHP Compile code without PHP sources. And you can take this NuGet package, which you can review and explore and open it. We can take this NuGet package, push it on your NuGet feed in NuGet.origo or something like that, and share it with your team or with others. And all it contains is a DLL file to the Compile PHP code and the specification of the NuGet package, which you can alter in the MS-build project file as you are used to. And it's a great way of sharing bigger libraries written in PHP or in another language. And I'm showing you this because now let's make a move to Visual Studio and demonstrate a razor and PHP. So we can get closer to the final demonstration, which will be after that. Imagine you have a few more files in your PHP project, for example. And you would like to write a new website and C-sharp. Let's say you have really old PHP project, and all the components, all the parts of your website are already written in your app. And now you are writing this new SB.NET Core NVC application. And you would like to, of course, make use of the already written code. Because in this way, you can slowly create a new project and reuse existing piece of code. You don't have to rewrite the code. Slowly create a new project and reuse existing piece of code. You don't have to rewrite everything from scratch and wait, for example, a year or two to make the new project working. So in this demonstration, we have three projects. I've prepared a PHP library, a PHP project as you see before. And what it does, yes, there is a small PHP code. And then there is a C-sharp project, regular one with regular Caster web server, with some index razor page. And what we do here, we'd like to take this existing PHP code and render it as a component on the razor page. And for this purpose, we can do it as before. We just create a PHP project. We create an NVC application. But there is an extension to the HTML object, which usually renders things like Action Link, checkbox, and so on. There is an extension called PHP. And you can literally take your name of your PHP file, put it as an argument to this PHP extension, and make the runtime to render your compiled PHP code at this point. So if you run this project as a command line, it'll again compile all the PHP stuff, compile all the C-sharp stuff, create the views, and so on. Let's put a breakpoint in here. Let's put a breakpoint in here. And let's put a breakpoint also in here. Yeah, it's still in there. So now you see we are debugging the razor page. And it seamlessly transferred to the PHP code. And now we are rendering the PHP code. It's all asynchronous. So that's why you don't see the razor on the call stack. And that's like it. That's everything you have to do. You can debug it, continue. And in the result, you see a part of code from razor and part of code from PHP. If you take a look on the source code, it's all a single HTML code. There are no frames or JavaScript or anything. It's like one piece of code. So nobody will ever notice there is some PHP on this razor page. The font size, sure, like this. No problem. So we can do this in another way as well. We can render a razor partial view in a PHP code, which is pretty much the same, but written in PHP. I guess it's in this file. Yes, it's in this file. There's the same extension for PHP code already written. And as you can see, we can write something like HTML and partial and type name of your partial view, which I have in here. We can also pass a model. It can be a C-sharp object or it can be a PHP object as well. So in this demonstration, we have class user as a PHP class. We pass it as a model for this partial razor view. And the partial razor view is stating it's accepting this user. So for an interview of the C-sharp project, it's a regular.net class. If we navigate to the definition, it generates something from metadata. But it's actually contained in the generated PHP library. So it doesn't care, actually. I did implement it in the PHP object. So let's start. Let's start this project and see what happens. So running, it has the breakpoint in PHP code. And if you put a breakpoint in here, you can see it transfers the execution to the razor partial view. And on the close tag, you can see now we are in PHP. It does a bunch of stuff. And then it continues in the razor view. It renders the razor thing and goes back to the PHP code. And in the result, there is your razor partial view rendered in a PHP page that was compiled into .NET. So that's how you reuse existing stuff from NBC application or from all the PHP application in other projects that are on a different platform, for example. And I was showing this for another purpose because what's great about a project, it handles larger projects than two or three PHP files. And we showed it before. But now we can all make it working together with razor and all the other stuff. And that's a bigger replication. And we've chosen a WordPress for this demonstration. So in this demonstration, we take the entire sources of WordPress, just pack it into an MS-built project file. And we create a NuGet package from the entire WordPress. And we use this NuGet package in the NBC application, in the ASP.NET core application, without configuring any web server or installing any PHP or anything like this. So maybe let's go back to Visual Studio Code. And I have something like, yes, it's SDK. And in here, we have a bunch of projects. One of them is WordPress folder. And it contains the entire sources of the WordPress or the WordPress application. And you don't have to actually take a look on the sources. The important thing is the project file. So we stated, target framework for the WordPress application is dotnet standard 2.0. We've prepared some property in here. Like in other C-sharp projects, we have no warning properties. So we can ignore some warnings. Because actually, PHP applications are full of issues, full of warnings, full of errors. And some of them are just not that important that I would like to care about. So for example, this one is about putting mandatory parameters after optional parameters, which is OK in PHP. In dotnet, you cannot do that. So the compiler shows you the warning. But for this demonstration, we are ignoring it. Also, we are compiling all the PHP files or the PHP except for some of them. And we are including some content files, like pictures and JavaScript files and CSS files, into the NuGet package. This is very important because if you create a NuGet package with the content files, then you don't have to do anything. You have a NuGet package with WordPress, and all its content right where you need it. And that's it. The rest is the same like before, with the one exception. We have a SDK project, which adds a few more features to the WordPress. And the SDK project is here. And it defines some interfaces that are not needed, but it also makes it extensible for our helper project that provides an extension method called use WordPress. So if you write this use WordPress method, if you call this use WordPress method in your SP.NET Core application, it does a bunch of stuff, like loading the WordPress into the SP.NET Core pipeline. And also, it enables, for example, SP.NET Core Response Caching, which is pretty cool, because everyone who ever configured the WordPress site knows you have to enable some caching plugins like WP Supercache or anything like this, which is not needed now, because we have .NET Core and we have this Response Caching middleware. So there's also a small application to test the WordPress and to run it on a Casterl. So as you can see, it's a regular Casterl site calling the use WordPress. So let's run this little sample. If you press something like a five, I guess, it compiles it compiles the entire WordPress, which takes a few seconds, and outputs a bunch of warnings, like the thousands of them. A lot of them are because of the unreachable code detected, because in PHP, can I open it? Yes, I can open it. Because in PHP, they like to make conditions like if a function exists, do this. And if class exists, do that. And the compiler knows the function exists. So it makes a lot of code unreachable, and it outputs you a warning for this. Anyways, now we are configuring the pipeline and stepping into the WordPress. And we are doing a bunch of stuff like we are reading the WordPress configuration from appsettings.json file. Because in WordPress, to configure our database or other things, you have to modify a source PHP file. And we don't like that. So we've replaced it with appsettings.json. So we load the configuration from appsettings.json. And then we configure the WordPress using the settings file instead of modifying the source PHP file. We also enable the response caching middleware. And dsdk also enables the short URL rewriting. So in WordPress, you have these short URLs, which doesn't refer to actual PHP files. But instead, they have to be parsed and passed to index.php. So in here, we configure the short URL rule using dsp.net core middleware. We pass the middleware to the pitchpy runtime, which will handle our requests and pass them to compile source files. And also middleware for static files. So all the JavaScript, CSS files, and images will be handled as well. So let's continue. I've already started MySQL Database, which is the most advanced topic of running WordPress on .NET, actually. So I already have MySQL Database. And yeah, it's running. So I guess I've configured it on port 5.044. So if we open the opening browser, not the ads, in here, it does some jittering and here it is. Well, not that slow. And in here, we have the entire application running on .NET. So you see a bunch of debugging stuff. You can, of course, put breakpoints in the PHP code somewhere, somewhere interesting like settings. OK, somewhere in here. So you can put breakpoints in a PHP code and do whatever I'm used to from the debugging application. Yes. But this is something we have shown like a year ago. And what's nice about this approach is compiling the WordPress or compiling the PHP application with this property called generate package on build. Yes. It means it creates in a NuGet package from this product file. And here we have one created from the WordPress. It's about 8 megabytes, 8 megabytes large. It contains the entire WordPress with the content files. So whenever I reference this NuGet package from my C-sharp application, I get all the content files as well. And in lib folder, there is this compiler to WordPress, including the XML documentation file, which is generated from the PHP documentation commands from the WordPress itself. So we call this package pitchpilot.wordpress. And we can use this package to run our new WordPress site without having any WordPress or without having any PHP files in my project, actually. So for these purposes, I've prepared a really small application on Kestrel. And it's this one. So there's the application with no PHP files at all. There's just one reference to that pitchpilot.wordpress NuGet package. And the rest is handled by .NET Build System itself. So we call this use.wordpress to install the WordPress into the request handler pipeline. And with few plugins that I will show later. But an important thing is there is no PHP code at all. We reference the PHP code from the NuGet package. And we can put the point as usual and run the application. Yep. So in here, we cannot step into it because it's compiled in the NuGet package. But you run it as usual. And we will see the same as before because we are running the same NuGet package as we've created before. But why would I do that? Why would I compile the WordPress to the .NET? There are a few reasons. As I've shown before, we can install this response caching mechanism that boosts performance of the WordPress site. So if we log out and go back to the site, the response time to make the request to the site is about two milliseconds. Because it just hits the SP.NET Core response caching middleware and gets me the output immediately. All I can do as well is extend the WordPress with a C-sharp. So if I have some components, some packages in C-sharp or as a NuGet package, and I don't have them in PHP, I can extend WordPress in C-sharp using these components. For example, in here, there's an additional widget in my dashboard that is actually written in C-sharp as a razor partial view. So we can use the same mechanism as I've shown in the demonstration before to render razor into widgets of the WordPress. And again, the WordPress source code was not modified at all. So the PHP code doesn't know it's coming from .NET. It's using the same syntaxes and same everything as it's used to. But it can be extended with a C-sharp in this way using the compiler. Another cool feature is I can write various plugins and short codes and have these app settings different for development and for production, which is something, again, it's not in the WordPress as it is in PHP. And if you take a closer look on the output of the project file, if you compile the project, there is no source files on the original WordPress. So that handles a lot of attacks to WordPress sites by modifying the source code, which is now not possible. You can, of course, disable modifications of the PHP files on your web server. But in here, it's coming as a single compiled WordPress site, which you can also test automatically on your Azure DevOps. It's called Azure DevOps, I guess, on your DevOps platform to check the integrity of all the plugins and everything and deploy just the compiled fully working tested application to your website. And also, as I was talking about the other two links, you can take use of the diagnostic window of Visual Studio, which I really like because it reveals me a lot of memory issues, a lot of exceptions, a lot of CPU leaks, and all the other issues I can have. So in here, when I'm browsing through the site and without the response caching because the response caching is disabled when I'm logged in, you can see the CPU is merely doing something. It's just a little peak and nothing else. And also, I can profile the application and see all the stuff I'm used to because it's very good practice to profile the application before you go to production, of course. And yes, that's it. I made it in 45 minutes. So that's actually everything I wanted to do. I wanted to demonstrate in this presentation. But yes, I guess I have a few more seconds. I can show you one more use of the .NET. I've prepared a little project in Visual Studio written in PHP code. And as you can see, it uses a Xamarin framework. So let me connect my phone somewhere into here. And where is it? And in the last two seconds, let me show you how the .NET is powerful for various reasons. You saw we can integrate PHP and .NET and all the stuff. But .NET provides you much more. .NET provides you better performance. You can publish your project to various devices, to Linux, macOS, Windows, and everything. You can, of course, make your application ultra-portable. And once you connect your phone to Visual Studio, you see it appears in the top menu. And you can just run any .NET project using the Xamarin framework on your mobile device. And I have an Android device in here. And as you know, .NET doesn't see a difference between languages. Once the language is compiled to .NET, you can do whatever you want with it. So what's PHP allows you to do is write an application for your mobile phone as well. So let it compile, deploying, building, installing target, doing some strong signatures, and deploying the DLL files to the phone, starting debugging, yes. Oh, and it's running. So in here, we have a little planet written in PHP running on Android device, which gives one more use case for the PHP language. I guess it would work for Apple and Windows phone as well, but I'm OK with Android. So that's it. I think I made it in 47 minutes. It's great. Thanks. So if you have any questions, I'm here. And I'll be glad to answer. If someone's listening at 2 AM, of course. Hey, Jacob, that's awesome stuff. We do have a couple of questions in the chat room. So we have some folks that were asking, does everybody get that performance bump when they drop in and they start using razor pages with PHP? Well, as you know, razor pages are compiled to .NET. So razor pages are strongly typed. And it can be written much more performant than PHP. And there is no performance drop because it's actually doing nothing. It's just calling the razor partial view PHP code. There is nothing performant that does. So there's no performance drop. So you get great performance when you're using razor with PHP. And there's also some questions here for folks that are just visiting a WordPress app, not an admin user, but if folks are just browsing to WordPress, do they also see that great performance coming through? Yeah, sure. Well, that's mostly because of the ASP.NET Core response caching middleware. Because locally, we have response in two milliseconds, which is great. So users will definitely notice the difference. But of course, if you configure another caching mechanism on your Apache web server or anywhere else, the result will be pretty much the same. In here, it's shorter, cleaner, and much more configurable than usual approaches. Cool. And one last question. Our friend, Ancient Coder, here in the chat room, is asking, WordPress has had major security attacks. How does your implementation of PeachPie with WordPress affect that security story? Oh, that's a good question. As you see, the WordPress is entirely on cloud, so you don't have any source files on your web server. So any attacks on these sources are not possible at all. Also, there is this ASP.NET Core and ASP.NET Core pipeline and your Azure web server, which catches a lot of attacks. And we've actually saw a lot of attacks on bugs in PHP. Since you don't have any PHP on your web server, these attacks are possible. So a lot of improvements and issues that are now in PHP like different runs or similar are simply not possible because it doesn't rather crash than allows you to modify and unsave. So a lot of attacks that are targeting PHPs are simply not possible with the compiler. That's it. Cool. And last question that I have here, I want to make sure I touch on. For folks that are browsing to a PeachPy-enabled website, is there an initial download that those folks see? PeachPy runs completely on the server, right? Yes. PeachPy is like a compiler in runtime on the server, so they don't notice. The only way how they can notice is to reveal the response headers of the web server. And they would notice there is x powered by a header with the value of PeachPy. So that's the only way how they can notice. But there is no downloading. There is no initial download at all. And so they won't notice. Fantastic. Well, thanks so much, Jacob. A number of the folks here in the chat room are pointing out that I've been doing a little bit of work with PeachPy on my channel. I know you've seen some of the stuff that I'm doing over there. So really great stuff. I can't wait to go a little bit further exploring PeachPy on my own. And it sounds like a couple of the folks here in the chat room are excited to give it a try with PHP on their own. So thank you so much. Yeah. Just think about putting all the goodness together with all the goodness of the PHP. Oh, my gosh. It's awesome. It's crazy. So thanks so much. We'll catch you later. And we're going to start getting ready for our next presentation. But in the meantime, we've got some quick words on view and webpack. Catch you later, Jacob. Thanks. Bye.