Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Saadi Shamsaee
@Saadi6688_twitter
however, i posted a new bug on the above bug page. is that fixed?
the edit files bug...
Saadi Shamsaee
@Saadi6688_twitter
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?
Jakub Míšek
@jakubmisek
@liesauer Nope, StringEncoding is a manner of run time, while csproj is purely compile time which produces a generic DLL that can run on various run times under various settings.
Calvin Baart
@calvinbaart
Seems that with the upgrade to dotnet core 3.0 the laravel travis builds were broken so that should be fixed now. Seems that the issues causing the most errors at this moment are:
Jakub Míšek
@jakubmisek
@calvinbaart thanks! peachpiecompiler/peachpie#549 has been fixed, the others are in progress. We might add some debug assertions so peachpiecompiler/peachpie#252 will fail instead of silent pass through ..
Calvin Baart
@calvinbaart

@jakubmisek I’m getting this error now: PHPUnit\Framework\WrappedException: System.ArgumentException: Enum underlying type and the object must be same type or object must be a String. Type passed in was 'System.Int64'; the enum underlying type was 'System.Int32'.
1961 at System.RuntimeType.IsEnumDefined(Object value)
1962 at System.Enum.IsDefined(Type enumType, Object value)
1963 at Peachpie.Library.PDO.PDO.setAttribute(Int32 attribute, PhpValue value)
1964 at Doctrine.DBAL.Driver.PDOConnection.__construct(PhpValue dsn, PhpValue user, PhpValue password, PhpValue options) in /home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:line 29

The only setAttribute the constructor does is for the statement class and the errmode. I’m guessing the errmode causes this exception

Jakub Míšek
@jakubmisek
thanks @calvinbaart , fixed!
Dani Llewellyn
@diddledani
lots of work occuring on a Sunday :-)
Calvin Baart
@calvinbaart
That fixed about 200 errors :)
Tests: 3953, Assertions: 7237, Errors: 791, Failures: 137, Warnings: 3, Skipped: 86.
->
Tests: 3953, Assertions: 7770, Errors: 587, Failures: 154, Warnings: 3, Skipped: 86.
Jakub Míšek
@jakubmisek
:)
Jakub Míšek
@jakubmisek

@calvinbaart commit peachpiecompiler/peachpie@874376a fixes variables not being passed by reference. So few more tests should pass now.

Also I see there is a lot of syntax errors in SQL queries?

Then some exceptions when reflecting closure's parameter I guess?

Feel free to post new issues :) we are getting closer to 1.0 release and it would be cool to have laravel at least partially working

Calvin Baart
@calvinbaart
@jakubmisek I think some of the SQL syntax errors are caused by invalid function of some of their helper functions (they
Use a lot of references in their helper functions)
I'll try to investigate some of them tonight
Calvin Baart
@calvinbaart

@jakubmisek I think something is going wrong with default arguments but I can't seem to figure out a small test case. Looking at this error for example:

7) Illuminate\Tests\Database\DatabaseEloquentBelongsToManyChunkByIdTest::testBelongsToChunkById
Illuminate\Database\QueryException: SqliteException: SQLite Error 1: 'near "from": syntax error'. (SQL: select  from "users" limit 1)
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Connection.php:625
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Connection.php:335
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Query/Builder.php:2142
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Query/Builder.php:2128
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Query/Builder.php:2572
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Query/Builder.php:2127
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Eloquent/Builder.php:520
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Eloquent/Builder.php:505
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel/src/Illuminate/Database/Concerns/BuildsQueries.php:143
/home/travis/build/calvinbaart/laravel-peachpie-sample/Laravel.Tests/tests/Database/DatabaseEloquentBelongsToManyChunkByIdTest.php:56

The code that errors out (DatabaseEloquentBelongsToManyChunkByIdTest.php:56) will be:

$user = BelongsToManyChunkByIdTestTestUser::query()->first();

Where first is defined as:

    public function first($columns = ['*'])
    {
        return $this->take(1)->get($columns)->first();
    }

When placing a print_r in first to check $columns I get no results (null). (PHP correctly echoes the ['*'] default parameter). Changing it to this however:

    public function first($columns = ['*'])
    {
        echo print_r(func_get_args(), true) . "\r\n";
        return $this->take(1)->get($columns)->first();
    }

Fixes it. It correctly gets the default value for $columns this time. The first method is in a trait used by the Builder class (returned instance of the query method).

ILSpy only shows this for the method first in the Builder class:

public virtual PhpValue first([DefaultValue(Type = DefaultValueAttribute.DefaultValueType.PhpArray, SerializedValue = new byte[]
{
    97,
    58,
    49,
    58,
    123,
    105,
    58,
    48,
    59,
    115,
    58,
    49,
    58,
    34,
    42,
    34,
    59,
    125
})] PhpValue columns)
{
    return <>trait_BuildsQueries.first(columns);
}

When using the func_get_args print_r ILSpy shows this (this version works):

public virtual PhpValue first(params PhpValue[] <arguments>)
{
    return <>trait_BuildsQueries.first(<arguments>);
}
Jakub Míšek
@jakubmisek
@calvinbaart awesome! you are right - default parameters with arrays in a trait method will be the cause of this ... I'll try to prepare a test case
Calvin Baart
@calvinbaart
Great :) Just ran a new test and it seems that all the relation errors are gone! (They are all replaced by the default arguments error though). So I think we are almost there for a functional Eloquent ORM
Jakub Míšek
@jakubmisek
@calvinbaart thanks :) default arguments have been "redesigned" and fixed just now, I hope it helps