{"id":25165685,"url":"https://github.com/fibonaccifox/peachpie.avalonia","last_synced_at":"2025-03-17T07:10:21.188Z","repository":{"id":178360130,"uuid":"661398251","full_name":"FibonacciFox/Peachpie.Avalonia","owner":"FibonacciFox","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-06T20:36:37.000Z","size":6262,"stargazers_count":33,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-05T00:44:55.559Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FibonacciFox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-02T18:05:39.000Z","updated_at":"2024-09-21T11:30:27.000Z","dependencies_parsed_at":"2023-09-27T23:16:07.616Z","dependency_job_id":"e59829c2-4e1a-4265-9204-f0500799cf17","html_url":"https://github.com/FibonacciFox/Peachpie.Avalonia","commit_stats":null,"previous_names":["fibonaccifox/peachpie.avalonia"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FibonacciFox%2FPeachpie.Avalonia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FibonacciFox%2FPeachpie.Avalonia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FibonacciFox%2FPeachpie.Avalonia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FibonacciFox%2FPeachpie.Avalonia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FibonacciFox","download_url":"https://codeload.github.com/FibonacciFox/Peachpie.Avalonia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989576,"owners_count":20379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T05:39:59.396Z","updated_at":"2025-03-17T07:10:21.170Z","avatar_url":"https://github.com/FibonacciFox.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![Build Status](https://github.com/FibonacciFox/Peachpie.Avalonia/blob/master/docs/logo/logo_ru.png?raw=true)\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/FibonacciFox/Peachpie.Avalonia/.github/workflows/PackagePublish.yml?branch=master\u0026event=push\u0026logo=nuget)](https://github.com/FibonacciFox/Peachpie.Avalonia/actions/workflows/PackagePublish.yml) ![License](https://img.shields.io/github/license/FibonacciFox/Peachpie.Avalonia)\n[![NuGet](https://img.shields.io/nuget/v/Peachpie.Avalonia.svg)](https://www.nuget.org/packages/Peachpie.Avalonia) [![downloads](https://img.shields.io/nuget/dt/Peachpie.Avalonia)](https://www.nuget.org/packages/Peachpie.Avalonia)  ![Size](https://img.shields.io/github/repo-size/FibonacciFox/Peachpie.Avalonia)\n\n## 📖 About\n\nThe **Peachpie.Avalonia** library will allow developers to easily create cross-platform applications for Windows, macOS, Linux, iOS, Android and web browsers in PHP in the .NET runtime.\n\n**Full .NET compatibility:** Compiled programs run in the redesigned [PeachPie](https://www.peachpie.io/) runtime, which is fully compatible with the PHP runtime.\n\n**Two-way compatibility:** the project allows hybrid applications, some of which are written in C#, and some in PHP. The parts will be fully compatible and will be able to interact seamlessly, all within the .NET framework.\n\n[**Avalonia**](https://avaloniaui.net/) is a powerful framework that enables developers to create cross-platform application using .NET\n\n## 🚀 Getting Started\n\nInstall .NET 8.0 SDK\n\n\u003e [!NOTE]\n\u003e[ ](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)[Download .NET 8.0]()\n\nRun from a command line (`.NET 8+`):\n\n```powershell\ndotnet new install Peachpie.Avalonia.Templates\n```\n\nThe templates should now be available in `dotnet new list`:\n\n```\nTemplate Name                        Short Name                 Language  Tags\n-----------------------------------  -------------------------  --------  -----------------------------------------\nAvalonia PHP App                     php.avalonia.app           PHP       Desktop/PeachPie/Xaml/Avalonia/Windows/Linux/macOS\nAvalonia PHP Library                 php.avalonia.lib           PHP       Library/PeachPie/Xaml/Avalonia/Windows/Linux/macOS\nAvalonia PHP Window                  php.avalonia.window        PHP       Desktop/PeachPie/Xaml/Avalonia/Windows/Linux/macOS\nPHP Console App                      php.console                PHP       Console/PeachPie\nPHP Library                          php.lib                    PHP       Library/PeachPie\n\n```\n\n# Creating a new Avalonia PHP Application\n\nTo create a new barebones php application called `MyApp` in its own subdirectory, run:\n\n```\ndotnet new php.avalonia.app -o MyApp\n```\nGo to the `MyApp` derictory `cd ./MyApp` and execute:\n\n```\ndotnet run\n```\n\nIf you've done everything correctly, you should see a project template like this:\n\n![TemplateApp](https://github.com/FibonacciFox/Peachpie.Avalonia/blob/master/docs/images/template_app.jpg)\n\n\n\n## How to create a Button control (good for any control) using code?\nUnlike basic Avalonia UI components, Peachpie.Avalonia form components must start with «Ux». These components are child classes of Avalonia's base UI components, but with some changes to make development easier. (In the future I plan to avoid inheritance, but for now creating controls would look like this)\n```php\n\u003c?php\n\nnamespace Views {\n\n    use Avalonia\\DevToolsExtensions;\n    use Avalonia\\Layout\\HorizontalAlignment;\n    use Avalonia\\Layout\\VerticalAlignment;\n    use Peachpie\\Avalonia\\Controls\\UxButton;\n    use Peachpie\\Avalonia\\Controls\\UxWindow;\n    use Php\\Output\\Logger;\n    use Views\\Pages\\HomePage;\n\n    class MainWindow extends UxWindow\n    {\n        public function __construct()\n        {\n            $this-\u003eInitializeComponent();\n\t\t\t//Create a button\n            $button = new UxButton();\n            $button-\u003eContent = \"I'm a super button, press me!\";\n            $button-\u003eHorizontalAlignment = HorizontalAlignment::Center;\n            $button-\u003eVerticalAlignment = VerticalAlignment::Center;\n\n            $this-\u003eContent = $button;\n\n            Logger::Info(\"Hello Peachpie Avalonia!\");\n        }\n\n\n        private function InitializeComponent(): void\n        {\n            Load();\n\n            if ( defined('DEBUG') ) {\n                Logger::Info(\"Debug Build!\");\n                //DevTools press F12 Debug build\n                DevToolsExtensions::AttachDevTools($this);\n            }\n        }\n    }\n\n}\n```\n\n### **The library supports the following event syntax:**\n\n```php\nuse Avalonia\\Interactivity\\RoutedEventArgs;\n\n$this-\u003ebutton1-\u003eon('Click', function(UxButton $sender, $RoutedEventArgs $e) {\n\tLogger::Info(\"Hello Peachpie Avalonia!\");\n});\n\n$handler = function(){\n\t/////////////////////\n};\n\n$this-\u003ebutton1-\u003eon('Click', $handler);\n\n\nuse Avalonia\\Interactivity\\RoutedEventArgs;\n\npublic function BurgerButton_onClickArgs(UxToggleButton $sender, RoutedEventArgs $e): void\n{\n\t$this-\u003eTitle = \"BurgerButton_onClickArgs function\";\n}\n\npublic function BurgerButton_onClick($sender, $e): void\n{\n\t$this-\u003eTitle = \"BurgerButton_onClick function\";\n}\n\n$this-\u003ebutton1-\u003eon('Click', [$this, 'BurgerButton_onClickArgs']) ;\n\n$this-\u003ebutton1-\u003eon('Click', [$this, 'BurgerButton_onClickArgs'], 'BurgerButton_onClickArgs') ;\n\n$this-\u003ebutton1-\u003eon('Click', [$this, 'BurgerButton_onClick'], 'BurgerButton_onClick') ;\n```\n\n\u003e [!IMPORTANT]\n\u003e\n\u003ePeachPie runtime allows working with .NET/CLR `event` class members in order to register and unregister callables. The following code depicts a sample C# class and a sample PHP program adding and removing an anonymous function (or any PHP callable) to it.\n\u003e\n\u003e\u003chttps://docs.peachpie.io/net/type-system/#c-event\u003e\n\n```php\n// add callable to the event handler:\n$hook = $button1-\u003eClick-\u003eadd(\n    function ($sender, $arg) {\n        Logger::Info(\"Click!\");\n    }\n);\n\n// remove callable from the event handler\n$hook-\u003eclose();\n```\n### Accessing a form component from xaml:\n\n```xml\n\u003cUxTextBlock Name=\"textblock1\" Foreground=\"#ECF0F1\" HorizontalAlignment=\"Center\" Text=\"Hello PeachPie Avalonia!\"/\u003e\n```\n\n```php\npublic UxTextBlock $textblock1;\n\n$this-\u003etextblock1 = $this-\u003eFindByName(\"textblock1\");\n$this-\u003eText = \"Hello\";\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibonaccifox%2Fpeachpie.avalonia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibonaccifox%2Fpeachpie.avalonia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibonaccifox%2Fpeachpie.avalonia/lists"}