Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:38
    jakubmisek closed #594
  • 12:38
    jakubmisek commented #594
  • Feb 23 20:39
    B-Esmaili starred peachpiecompiler/peachpie
  • Feb 23 14:59
    jakubmisek closed #681
  • Feb 23 14:59
    jakubmisek commented #681
  • Feb 23 14:58
    jakubmisek assigned #681
  • Feb 23 14:58
    jakubmisek opened #681
  • Feb 23 14:56

    jakubmisek on master

    dynamic conversion between clas… (compare)

  • Feb 23 14:42

    jakubmisek on master

    overriding resolution handles e… (compare)

  • Feb 22 14:12

    jakubmisek on master

    $(OutputType) msbuild property (compare)

  • Feb 21 20:58
    DRSDavidSoft commented #663
  • Feb 21 19:23
    jakubmisek edited #678
  • Feb 21 19:23
    jakubmisek edited #678
  • Feb 21 19:23
    jakubmisek edited #678
  • Feb 21 19:23
    jakubmisek closed #678
  • Feb 21 19:23

    jakubmisek on master

    support for define constants in… (compare)

  • Feb 21 17:05
    jakubmisek edited #678
  • Feb 21 17:04
    jakubmisek commented #663
  • Feb 21 17:04
    jakubmisek commented #663
  • Feb 21 17:03
    jakubmisek closed #663
Jakub Míšek
@jakubmisek
BTW sadly, PHP does not have code scopes, only local and global. So it destroys its local variables on the very end of the function block (as I remember)
Calvin Baart
@calvinbaart
Just wrote some test code and BTW sadly, PHP does not have code scopes, only local and global. So it destroys its local variables on the very end of the function block (as I remember) seems to be correct. It only calls destruct at the end of the function (or when I dereference the last value, for example $obj = new TestClass(); $obj = new TestClass2();, TestClass destruct will be called here)
Jakub Míšek
@jakubmisek
Seems correct, we can keep track of a few simple cases and call __destruct() (or Dispose in our case) like PHP does. Then we'd add some assertions so we'll be notified if __destruct was not called so implementor (you and us) would know there might be an issue.
latest commit disables finalizers
Daniel Llewellyn
@diddledan
You may remember ages back I mentioned that adding the code-based AppInsights thing from azure to a wpdotnet was causing exceptions to fire. I finally took some time to figure it out - it's in the WPdotnet cache mechanism which saves the headers of the response when adding to the cache and then tries to re-add those headers in a cached response. The response therefore tries to add a second Request-Context header because AppInsights adds one to every response before wpdotnet then adds the one from the original caching request
I worked around it by adding an if (header.Key != "Request-Context") {} around the re-adding mechanism when serving a cached response
it might be better to not cache the header in the first place rather than avoiding it when emitting the cached responses
        async Task WriteResponse(HttpContext context, CachedPage page)
        {
            foreach (var header in page.Headers)
            {
                if (header.Key != "Request-Context")
                {
                    context.Response.Headers.Add(header);
                }
            }

            await context.Response.Body.WriteAsync(page.Content, 0, page.Content.Length);
        }
^^^^ From my edited copy of PeachPied.WordPress.AspNetCore/Internal/WpResponseCaching.cs
LORDofDOOM
@_LORDofDOOM__twitter

Hi Guys,

first of all, it's a really great project and I'm already able to build wordpress with some plugins :-) Just some questions (i hope this is OK in this chatroom):

  • Is there any option to compile wordpress plugins directly from the wordpress folder (like themes, without create a separate plugin and reference it), the idea here is that I want to be able to create a compiled assembly from a "normal" Wordpress installation and check if plugins will work) ? I've tried to simply copy some plugins to that folder, it also seems to get compiled but I dont see them in installed plugins.

  • You write in the Wiki that e.g. elementor is supported, I've also get it compiled but it dont run in debug mode (throw exceptions because of Logging) and in release mode it runs but I'm not able to use it (type error on save) - Did you manage this plugin differently (in terms of compiling), and if so, is there any repository for it ?

Jakub Míšek
@jakubmisek
@diddledan thanks! I'm not aware of AppInsights but we should definitely not cache certain headers
Jakub Míšek
@jakubmisek

@_LORDofDOOM__twitter

BTW that's why we have prepared https://github.com/iolevel/peachpie-wordpress where you use already compiled wordpress and just add your plugins and themes. The project is ready for that.

  • do you have a link to the wiki? you might be right that we tested it in release only, or we have had an older release
Benjamin Fistein
@bfistein
@jakubmisek he's referring to this. We briefly tested it, made sure it compiles and randomly clicked through it, so it's possible a newer release ir something specific doesn't work
LORDofDOOM
@_LORDofDOOM__twitter

@jakubmisek Thanks you for your fast answer :-)

My question was more like if I'm able to compile a already prepared wordpress installation.

So if I recompile and have plugins into https://github.com/iolevel/wpdotnet-sdk/tree/master/wordpress/wp-content/plugins folder netcore will compile this files. Possibly I'm wrong, but if I copy files to the https://github.com/iolevel/wpdotnet-sdk/tree/master/wordpress/wp-content/themes folder the functions of the theme are working as expected, so in it's base thats the same thing as for a plugin, but the plugins dont get recognized (but they are getting compiled and also copy as content in output folder, so they should work). This would be pretty helpful to just try out some plugins without the creation of a external assembly and even to resolve references between plugins, so this is my next question :-)

I'm also not really sure how cross references are currently handled. If for example a plugin check if woocommerce exists and want to include it to show different options, is this handled ? Because on compile time it should not know about the existence of woocommerce. Or do I need to add additional reference into the plugin to woocommerce ?

Yes, I've read the Wiki and I've tried to compile elementor in release and debug mode (multiple versions, also the newest one 2.7.3), in debug mode it compile but throw exceptions because of missing classes (seems to be something in Logger class) and in release mode it loads normally but I cant add e.g. a image (type error on aspnetcore side on save)

Benjamin Fistein
@bfistein

@_LORDofDOOM__twitter regarding the bugs with Elementor - that's totally possible, lots of things have changed in PeachPie since we last tested it and who knows what changed in Elementor itself. I definitely didn't get an exception back when I tried about missing classes, so they might have added something. It would be really great if you could submit these exceptions in issues with some detailed info (stack trace, how to reproduce or something like that) and we'll take a look at them. The adding an image definitely sounds like a bug on our side.

Regarding the first part of your question, I'll leave that up to @jakubmisek .

Saadi Shamsaee
@Saadi6688_twitter
Hi. When the 2 bugs i reported will be fixed? Customify theme & Persian Calendar plugin. is there any wp.net daily(or weekly) changelog in your websites?
some Windows server Hosts don't support MySQL. is there a possibility to use SQL Server for WP.NET? SQL Server performance is lower than MySQL? is it true?
Benjamin Fistein
@bfistein
@Saadi6688_twitter we don't have a timeline for those issues, they are not our priority. Feel free to contribute to this open source project by fixing them or maybe someone from the community will. There is no changelog, but you can see the list of commits as well as the release notes.
Saadi Shamsaee
@Saadi6688_twitter
Hi Jakub. This bug seems to have been fixed. Can you publish the revised version of wordpressdotnet? thank you. iolevel/wpdotnet-sdk#41
however, i posted a new bug on the above bug page. is that fixed?
Saadi Shamsaee
@Saadi6688_twitter
the edit files bug...
And a question: Is it possible to automatically update WordPress under .NET after every WordPress update under Php? how is it possible? No need to recompile?
Dave Hutton
@davehutton
Hi all, awesome project so far! I'm incorporating peachpie / wordpress into my existing asp.net core 2.2 app. I'm working with the sample app atm (https://github.com/iolevel/peachpie-wordpress). Can anyone help me configure routing so wordpress can live under /content instead of / (root)? I'm trying to configure this sample project correctly before I move it over to my app as my existing app already routes root (/) back to the login screen. I've configured routing for razor pages and mvc but not sure how to configure this. I tried putting the below in startup and it works on the first page but subsequent pages get redirected back to root and subsequently fail:
        app.Map(new PathString("/content"), wp =>
        {
            wp.UseWordPress(path: "wordpress");
        });
amilcarwong
@amilcar34706591_twitter
Hi everyone, I need your support: what is your opinion about (my system is in aspnet but isn't a cms): 1) use worpress for business and marketing people---------> peachpie translate to ----> aspnet core ? the normal scenary is to have worpress and wish to migrate to aspnet. my scenary is the opposite
thanks in advance
Dave Hutton
@davehutton
I went ahead and ported the peachpie / wordpress stuff over to my existing project and the routing is already working correctly. I'd still be interested to know how to configure it in the github project, but my primary search now is how to require authentication (using asp.net core 2.2 identity) before a user can see the WordPress contents. If they aren't logged in they should be redirected back to my login page. Any other path already redirects back to my login page but I'm guessing because I'm using IApplicationBuilder map that it has its own rules. I didn't see anything obvious that would configure it to redirect if the user isn't logged in. Any idea on how I would set that up? I'm still using my code I posted above. TIA!
Jakub Míšek
@jakubmisek
@davehutton moving wordpress under /content can be achieved with a custom URL Rewrite rule (app.UseRewrite) as I know.

To disallow the anonyous access on wordpress content, there is something in the asp.net core config (I don't remember the configuration option for that)

For overriding wordpress authentication you may need to write a WordPress plugin that overrides the wp-login and authenticates a wp user using aspnet core identity instead of querying wp database.

Benjamin Fistein
@bfistein
@amilcar34706591_twitter not totally sure what exactly you mean - like using WordPress as a frontend or CMS for your ASP.NET website? So you have a system in ASP.NET and you want to manage it using WordPress so that business/marketing people can edit stuff, is that right? I don't see why not, seems like a legitimate use case.
Byron Kleingeld
@crims0nSpyre_twitter
Hi @jakubmisek, it's crims0nSpyre from Twitter. Should I simply zip up the entire code base for you and where can I drop it?
Created in VS 2019
amilcarwong
@amilcar34706591_twitter
thanks very much @bfistein , yea --> "So you have a system in ASP.NET and you want to manage it using WordPress so that business/marketing people can edit stuff". i am researching about how migrate my aspnet html to wordpress, can you give to me your opinion about how migrate?
Benjamin Fistein
@bfistein
you want to integrate WP into your ASP.NET site? I'm not totally sure what you mean, sorry
amilcarwong
@amilcar34706591_twitter
with this objective --> "So you have a system in ASP.NET and you want to manage it using WordPress so that business/marketing people can edit stuff" . what is your opinion about my next step? for me my next step is to migrate my aspnet to wordpress so this way my marketing people can edit and then use peachpie over my new wordpress. make sense this?. thanks
Dave Hutton
@davehutton

@amilcar34706591_twitter is wanting to do exactly what I'm doing or close to what I'm doing - make the content management of pages available via wordpress so developers aren't spending their time updating pages, text, images, etc. I'm in an office of marketing folks myself and there's a lot of day-to-day changes required on many of our webpages - change this date, swap picture, etc. There's enough of it that it can be very distracting and a waste of developer resources.

I think the first thing you should do is get your app updated to at least 2.1 if not 2.2. Then look at the github projects available where wordpress is already set up in an asp.net core solution. Then look at porting it over to your own app - that's what I did anyway. I'm not done yet as I'd really like these pages edited from wordpress yet viewable seamlessly within my asp.net app - ie. pages shown with existing _Layout menus and other elements surrounding the wordpress pages, requiring authentication via identity before they can view those pages, show wordpress pages within razor views as a more seamless alternative to an iframe, etc.

For my own question, I'm wondering how to pull in a WordPress page into a razor page? I found this article (https://www.peachpie.io/2018/07/render-php-file-in-razor-view.html) explaining how to load a php script into a razor view but I'm not sure how that translates into pulling a complete WordPress page into a razor page? Wordpress tends to use pretty links vs. a viewcontent.php?Page=1 or something similar that might work in this context. But I'm not a WordPress expert so maybe there's already a wordpress 'script' way of loading a page that would work with @Html.Php?

TIA!

amilcarwong
@amilcar34706591_twitter
@davehutton thanks very much, I continue to research and I will post any good info about my process. thanks for the link and the guide.
amilcarwong
@amilcar34706591_twitter
I am reading about basic vs headless vs decoupled cms
what is your opinion about what version is peachpie? my ideal solution is easy cms for my marketing team but easy for the developer and update system and take care with the performance. scale features
mashadow
@panalgin
hey guys, total noob here, how can I read the key pressed by user in a peachpie console application ?
searching for like half an hour but nowhere I could find some counterparts of Console class in php/peachpie
mashadow
@panalgin
stupid me
<?php
if (PHP_OS == 'WINNT') {
  echo '$ ';
  $line = stream_get_line(STDIN, 1024, PHP_EOL);
} else {
  $line = readline('$ ');
}
?>
Dave Hutton
@davehutton

I deleted my ramblings before and am summarizing my solution here. Btw do you have any sort of documentation wiki or discussion forum or something where you can centralize all questions and solutions?

I used jquery's .load to pull in a page based on its relative path and adding the id of the div I wanted to include (I used #content).

To protect wordpress so only an authenticated user could see the content or log in as admin, I used the below:

        app.MapWhen(context => context.User.Identity.IsAuthenticated && context.Request.Path.Value.StartsWith("/content"), wp => 
        {
            wp.Map(new PathString("/content"), wpMapper =>
            {
                wpMapper.UseWordPress();
            });

        });
Jakub Míšek
@jakubmisek
@panalgin hi, yes that's the point of PeachPie to make it the same as in regular PHP :)
@davehutton nice! we have only the documentation and issues on github .. pull requests to docs are always welcomed https://github.com/peachpiecompiler/peachpie-docs/tree/master/docs/scenarios :)
medvedy
@medvedy
Hello Guys, I'm just going my first steps with PeachPie and WordPress. I followed the instructions on Food for Thought: WordPress Plugin in C# but when I try to activate the plugin in the WP Admin area I get the error message "InvalidOperationException: Class 'MyWpPlugin' not found". Build seems OK. Is there anywhere a sample for a C# WP plugin which might help me? Thank you very much for your help :-)
Jakub Míšek
@jakubmisek

@medvedy nice! The issue is you have to make <PackageReference> from wordpress to your C# plugin project (that's why PHP code does not see the C# class)

Also you may take a look on a complete sample e.g. at https://github.com/iolevel/peachpie-wordpress/blob/master/app/Plugins/ShortcodePlugin.cs

medvedy
@medvedy
@jakubmisek Thanks for your reply! Can you tell me what I have to do to make the ShortcodePlugin available in the WP admin area? Currently I see only the Hello Dolly plugin.
Jakub Míšek
@jakubmisek

@medvedy actually the C# plugin is always enabled (it is so called must-use plugin).

In order to "see" it in Dashboard / Plugins, you'd need to make a little hack - You have to create a dummy WordPress plugin; e.g. a PHP file "shortcodesomething.php" with standard WordPress commentery at the beigning of the file, and place it into wp-content/plugins folder. ... (still the C# plugin would be always enabled; so you would have to check in the C# code through WordPress API, that shortcodesomething has been enabled :)

medvedy
@medvedy
@jakubmisek Thank you very much!
L!εsAμεr
@liesauer
can i set Context.StringEncoding in the csproj?