Coder Social home page Coder Social logo

peachpie-wordpress's Introduction

This project demonstrates how to start an ASP.NET Core server, integrate WordPress into its pipeline and add additional PHP plugins into it.

WordPress

Even though the project is noticeably small, it contains the entire WordPress CMS. How? This complex PHP web framework was already compiled into the .NET Standard library (see PeachPie compiler platform for more information) and packed into a NuGet package. This demo may just reference it.

To find out more about PeachPie, check out our resources, which includes tutorials, benchmarks and articles on PeachPie.

WordPress PHP Plugin

With this approach it is finally possible to have a project containing only the plugin. WordPress itself is already compiled and the plugin has a dependency on it (like any other C# app you would make).

The build process will do following:

  • compiles .php files within the PeachPied.WordPress.MyPlugin directory. Note that the path wp-content/plugins matters.
  • packs the compiled DLL together with content files (like images, scripts etc.) into a NuGet package.
  • copies the project content into the application output directory, together with WordPress content files extracted from its NuGet.

WordPress C# plugin

The project takes advantage of the wpdotnet SDK which provides a C# abstraction IWpPlugin. Objects of this type can be passed to the WordPress middleware (see UseWordPress) and hook onto filters and actions available in the WordPress API.

// TODO: add link to additional info about the wpdotnet SDK & WordPress API

Configuration

The configuration itself serves as a demonstration of combining a legacy PHP application with .NET. The demo takes advantage of the ASP.NET Core configuration mechanism, namely the files appsettings.json, appsettings.deployment.json and appsettings.production.json. This allows for having a different configuration for each environment without the need of altering the source code of the project.

// TODO: add read more about asp.net core config

Sourceless Distribution

The WordPress package was already configured, so the original PHP source code is not a part of the NuGet nor of the compiled DLL. In case of additional plugins (see PeachPied.WordPress.MyPlugin), it depends what source files are needed in run time. Usually only the main plugin file (containing the WordPress metadata) has to be distributed together with the DLL, so that WordPress can read its content and work properly. The other files can be excluded from the package.

As a result, this project serves as a demonstration of:

  • distributing the WordPress plugin without its source codes
  • build and maintain plugins separately as separate NuGet packages
  • maintaining/providing plugins with a dependency on a certain WordPress version
  • signing the plugin with a private key
  • possibly obfuscating the DLL

peachpie-wordpress's People

Contributors

bfistein avatar jakubmisek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.