Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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
Calvin Baart
@calvinbaart
Jakub Míšek
@jakubmisek
nice, this never worked .. at least now it throws an exception
Calvin Baart
@calvinbaart
@jakubmisek after the fix for #570 I tried building again but that resulted in a Stack Overflow during compilation: https://travis-ci.com/calvinbaart/laravel-peachpie-sample/builds/133804194 I then tried building in Debug mode instead to hopefully get some more info and that resulted in this error: https://travis-ci.com/calvinbaart/laravel-peachpie-sample/builds/133907933 (I don't think that assertion is related to the Stack overflow though)
Jakub Míšek
@jakubmisek
Thanks @calvinbaart the assertion might be cause of it, but who knows :) will try to fix it and try your project
Dani Llewellyn
@diddledani
in PeachPied.WordPress.AspNetCore/RequestDelegateExtension.cs there's a reference to WP as a type both in code an documentation comments. VS complains that the type is undefined. This type is defined in the WordPress PHP code IIRC. Is there something we can do to let VS know about it for better "go to definition" and such?
Dani Llewellyn
@diddledani
no idea what this one is doing:
Severity    Code    Description    Project    File    Line    Suppression State    Suppression State
Error    PHP1018    Class 'WPMailSMTP\MailCatcher' doesn't implement abstract method System\IDisposable::Dispose()    net.WordPress.plugin.wp-mail-smtp    C:\Users\yabea\source\repos\diddledan\bowlhat-wpdotnet\net.WordPress.plugin.wp-mail-smtp\wp-content\plugins\wp-mail-smtp\src\MailCatcher.php    16
Dani Llewellyn
@diddledani
this is the most reduced I can make that failure - it's got a copy of WPDotNet rather than relying on the -beta8 release because it only fails with master: https://github.com/diddledan/WPDotNet-PP-0.9.500-Inheritance-Test/tree/master/Inheritence%20Test
Jakub Míšek
@jakubmisek
@diddledan once you compile the WP project, the reference to WP class will be resolved
@diddledan hmm the error might be caused by mismatch in PeachPie versions
Jakub Míšek
@jakubmisek
@calvinbaart getting stack overflow in my test case as well, traits need some fixes when they are compiled in a separate assembly and referenced
Calvin Baart
@calvinbaart
Great that you found it! In the future should I just create a ticket on github for it? (I'm a bit weary to create github issue's without providing any information)
Jakub Míšek
@jakubmisek
@calvinbaart if you'd know the issue :) create a ticket please, but this one was pretty tough ...the latest commit peachpiecompiler/peachpie@e7c7d08 fixes several issues with traits being used from within a compiled library
Calvin Baart
@calvinbaart
@jakubmisek Yea, it's more that build issues just saying "Stack overflow" will be quite hard to create a proper ticket for. Seems that I'm still getting the Stack Overflow with the latest commit: https://travis-ci.com/calvinbaart/laravel-peachpie-sample/builds/134230099
Jakub Míšek
@jakubmisek
@calvinbaart thanks, so there is more occurances of the issue, will be fixed!