This commit is contained in:
Tomas Husak 2021-07-23 08:36:14 +02:00
Родитель 50822c6e49
Коммит 8277e9e003
3 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -6,11 +6,11 @@ Before we will start to talk about using classes provided by `Peachpie.Blazor`,
Create a standard Blazor WebAssembly application (with .NET 5) and tick ASP.NET Core hosted.
<img src=".\images\creating-web-assembly.png" alt="VS dialog" style="zoom:50%;" />
![VS dialog](.\images\creating-web-assembly.png)
We have to add a package reference for `Peachpie.Blazor` library to `BlazorApp.Client` and `BlazorApp.Server` projects in order to be able to use helper classes providing script navigation and execution.
<img src=".\images\nuget.png" alt="VS dialog" style="zoom:50%;" />
![Nuget](.\images\nuget.png)
Now, we have to add support for PHP in the `WebAssemblyHost` of `BlazorApp.Client` project. Because of Blazor specification, we have to add reference on a type defined in the additional assembly in order to make the assembly be downloaded with the `BlazorApp.Client`.
@ -175,5 +175,4 @@ For those, whose are familiar with Blazor, the code above should be understandab
At first glance, this way of adding PHP to Blazor can be considered difficult to use, but it enables utilizing a smart diffing algorithm during rendering. Hence, we can also create render-demanding applications like games by using this way. There is an [example](https://github.com/peachpiecompiler/peachpie-blazor/tree/dev/docs/src/Tests/Examples/WebGame) of a simple Asteroids-like game, which is fully implemented by PHP and executed as a client-side application. We can see a screenshot from this game below.
<img src=".\images\asteroids.png" alt="screenshot" style="zoom:60%;" />
![Screenshot](.\images\asteroids.png)

Просмотреть файл

@ -23,7 +23,7 @@ Integration of Blazor and PeachPie enables executing PHP scripts on a client sid
You can see a simple PHP web application, which is created as a Peachpie project and downloaded to a client by only one initial request below. The next navigation in the website is offline, using the Blazor environment.
<img src=".\images\video1.gif" alt="Demo" style="zoom: 67%;" />
![Demo](.\images\video1.gif)
## Remarks

Просмотреть файл

@ -1,10 +1,10 @@
# PHP JavaScript interoperability
The interoperability is interesting part of the integration. We are able to call JS from PHP and vice versa.
Interoperability is an interesting part of integration. We are able to call JS from PHP and vice versa.
## Calling JavaScript
When we want to call JS function, we just use prepared methods `CallJsVoid` or `CallJs`, which takes the method names, method parameters and calls the desired function for us.
When we want to call the JS function, we just use prepared methods `CallJsVoid` or `CallJs`, which takes the method names, method parameters and calls the desired function for us.
```php
<?php
@ -14,7 +14,7 @@ When we want to call JS function, we just use prepared methods `CallJsVoid` or `
## Calling PHP
We can also call PHP function, when there is an instance of `PhpScriptProvider` or `PhpComponent`. We just call `window.php.callPHP`, which takes the function name and its parameter as JSON structure.
We can also call PHP function when there is an instance of `PhpScriptProvider` or `PhpComponent`. We just call `window.php.callPHP`, which takes the function name and its parameter as JSON structure.
We can see an example of usage in the example below.