Skip to content

Integrating PHP into C# or vice versa

Why it matters

Leverage the best of both worlds. Some libraries are simply awesome in PHP, others are robust and secure in .NET. With PeachPie, you don't have to choose or make compromises - simply pick whichever platform provides the best value in the given area.

What you get

PeachPie allows for both-way interoperability between PHP and any .NET language, which enables you to seamlessly integrate libraries from either language into your application. You can therefore utilize libraries from either ecosystem that best suit your particular needs or inter-connect your application stack if it consists of both PHP and .NET. Instead of using costly API calls, marshaling, or roundabout integrations, you can natively use PHP apps or libraries within .NET or vice versa.

Same-Process Interoperability between PHP and C#

Having both C# and PHP projects together within a single .NET solution allows for seamless interoperability and continuous development. One project can leverage on the other one or vice versa. Moreover, the PHP application can take advantage of NuGet dependencies, providing it with thousands of high-performant well-tested components.

Adding dependencies

On the other side, all the work already implemented in the PHP project gets available to the .NET solution. Developers appreciate the full-blown IntelliSense, just like that:

IntelliSense for PHP Objects

The integration is well understood by the .NET toolchain. From the C# developers’ perspective, they don’t have to even notice there was PHP at all.

This approach allows you to re-use all of the PHP libraries in the .NET application or it allows you to provide an existing PHP application to the new .NET customers.

Moreover; the PHP project understands .NET dependencies as well. This allows extending the existing PHP applications with the use of .NET components.

Case in point

A client from the entertainment industry had a robust backend written in C#, but needed to provide a user-friendly frontend and CMS for their clients. With PeachPie, they were able to use the rich WordPress ecosystem as the frontend portion, simply by integrating our WpDotNet nuget into their app. This saved our customer months of development time and allowed them to use the tried and tested WordPress world instead of developing the site from scratch (or using tedious .NET CMSs).

References:

  • Reference a PHP project


    Learn how to provide PHP code as a dependency to be referenced by C# projects.

    Learn More

  • Create a NuGet package


    Pack your PHP projects to provide the library functionality across .NET projects.

    Learn More

  • Project file reference


    How to set up your MSBuild project file - the basic XML file that describes the build process and other properties.

    Learn More

  • Build hybrid apps


    Understand how to leverage both PHP and .NET within one application.

    Check Sample