by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    codemonkeynorth
    @codemonkeynorth
    but that last one doesnt work in 0.15.1
    Luc D
    @LucArthos_gitlab
    hey @atanas-dev just to let you know that on your doc, the left panel seems to always be the plugin one: when you're trying to read the theme doc, you are redirected to the plugin one https://docs.wpemerge.com/#/starter/theme/overview
    Atanas Angelov
    @atanas-dev
    @LucArthos_gitlab I can't see any problem with it - the sections follow the same style but clicking through them works for me.
    @codemonkeynorth in order to maintain a lower PHP version requirement a simpler DI solution was used (Pimple) which doesn't have automatic injection so your last snippet is the way to go (specifying every class that requires a dependency in the container; then setting the passed dependency as a prop on the class in its constructor).
    The current plan for the next major version (2.0) is to bump the PHP requirement and will use a more powerful container that will auto-wire dependencies.
    codemonkeynorth
    @codemonkeynorth
    @atanas-dev thanks. that last solution doesn't work in 0.15 though? it does in 0.16
    Atanas Angelov
    @atanas-dev
    nothing was changed about the container itself in 0.16
    codemonkeynorth
    @codemonkeynorth
    it just tells me my HomeController constructor had 0 arguments passed and expected 1
    Atanas Angelov
    @atanas-dev
    you can check the internal classes and they use the same pattern
    codemonkeynorth
    @codemonkeynorth
    Route::get()->where( 'is_front_page' )->handle( 'HomeController@index' );
    class HomeController { public function __construct(DatesService $datesService) {
    that ServiceProvider injection of DatesService into HomeController doesnt seem to get called in 0.15
    Atanas Angelov
    @atanas-dev
    is the injection done via ::class? Is the ::class call fully qualified because if you are calling it from a file with a different namespace then you would register a non-existing class as the key in the container
    codemonkeynorth
    @codemonkeynorth
    and then by DatesService::class yes
    Atanas Angelov
    @atanas-dev
    can you var_dump both ::class references and make sure both are correct?
    codemonkeynorth
    @codemonkeynorth
    ive switched it to ['dates_service'] and it still doesnt work
    Atanas Angelov
    @atanas-dev
    var_dump HomeController::class first
    codemonkeynorth
    @codemonkeynorth
    string 'App\Controllers\Web\HomeController'
    Atanas Angelov
    @atanas-dev
    is that the correct namespace and class name in HomeController.php?
    codemonkeynorth
    @codemonkeynorth
    yes
    Atanas Angelov
    @atanas-dev
    can you please copy-paste the $container[ ::class ] declaration you use in 0.15 and the namespace + class name definition from HomeController.php?
    codemonkeynorth
    @codemonkeynorth
    provider...
    use App\Controllers\Web\HomeController;
    use App\Services\DatesService;
    class DatesServiceProvider implements ServiceProviderInterface 
    {
        public function register ( $container ) {
        $container[ DatesService::class ] = function ( $container ) {
                return new DatesService();
        };
        $container[ HomeController::class ] = function ( $container ) {
                return new HomeController( $container[ DatesService::class] );
         };
    sorry hang on
    HomeController...
    namespace App\Controllers\Web;
    use App\Services\DatesService;
    class HomeController {
      public function __construct(DatesService $datesService) {
    Atanas Angelov
    @atanas-dev
    Can you add an exit statement before $container[ HomeController::class ] to confirm this code is actually executed
    codemonkeynorth
    @codemonkeynorth
    the register is definitely firing if thats what you mean
    if i remove the injection on the constructor from the HomeController so it doesnt break and then do var_dump(Application::getContainer()) i can see the closures in the container
    'App\Services\DatesService' => 
            object(Closure)[5177]
              public 'this' => 
                object(App\Services\DatesServiceProvider)[5154]
              public 'parameter' => 
                array (size=1)
                  '$container' => string '<required>' (length=10)
    so this would work datesService = Application::getContainer()[DatesService::class];
    i also see the other closure in the container
    'App\Controllers\Web\HomeController' => 
            object(Closure)[5178]
              public 'this' => 
                object(App\Services\DatesServiceProvider)[5154]
              public 'parameter' => 
                array (size=1)
                  '$container' => string '<required>' (length=10)
    Atanas Angelov
    @atanas-dev
    Found the issue - it's a bug when resolving controllers specifically. In 0.15 the app expects controller names in the container to be prefixed with \ but ::class does not return a leading \ so it doesn't get found.
    The easiest way to fix this locally is to prepend \ in the declaration for controllers only like this:
    $container[ '\\' . HomeController::class ] = function ( $container ) {
        return new HomeController( $container[ DateService::class ] );
    };
    codemonkeynorth
    @codemonkeynorth
    great thanks
    codemonkeynorth
    @codemonkeynorth
    confirmed working
    Luc D
    @LucArthos_gitlab
    hey @atanas-dev, I've downloaded the latest version of WPEmerge theme, I've installed it and am ready to work on it. in config.json I've indicated my local URL for the dev site, but when I yarn hot, I'm served at localhost:3000 a page which shows the files in the theme directory, not the site itself. Am I missing something in that new version?
    Luc D
    @LucArthos_gitlab
    (in config.json, I've tried to add hotUrl with the address of my local site, I've searched through the files, and through the doc, but no luck so far)
    Atanas Angelov
    @atanas-dev
    @LucArthos_gitlab this sounds like the previous version of the theme, not the latest.
    What is the version number listed at the top of the composer.json file?
    Luc D
    @LucArthos_gitlab
    0.16.1
    codemonkeynorth
    @codemonkeynorth
    Dont need to go localhost:3000 anymore with new version
    just go to your normal local address
    Luc D
    @LucArthos_gitlab
    i'm discovering it. so what's the "hot" address, then? the normal local address?
    ok, i'll give it a try, thanks
    codemonkeynorth
    @codemonkeynorth
    its in the release notes
    Luc D
    @LucArthos_gitlab
    thanks
    did skip that, i'll go read it now
    codemonkeynorth
    @codemonkeynorth
    “ Browsersync has been replaced with Webpack Dev Server. Proxying your website in yarn hot mode is no longer required.”
    Luc D
    @LucArthos_gitlab
    i'm on it, thanks :)
    Luc D
    @LucArthos_gitlab
    getting a hold on the new architecture (and discovering the service providers). what would be the smartest way to include a custom walker? I'm a bit at a loss: a service provider (but how do I bootstrap it?) ? a controller ('walker' => new MyApp\Controllers\Web\CustomWalker(),?) ? a helper (same question, how do I use it?) ? thanks by advance!
    Atanas Angelov
    @atanas-dev
    If you're referring to menu walkers, then then Controllers namespace is not a good fit. You can make your own app/Walkers/ directory to use MyApp\Walkers as the namespace for them, for example.
    To bootstrap a service provider, you have to include it in your 'providers' configuration key - more info here: https://docs.wpemerge.com/#/framework/tools/service-providers
    For the rest, there's docs here (that are getting more updates soon as well): https://docs.wpemerge.com/#/starter/theme/what-goes-where
    Tom K.
    @tomkeysers
    @LucArthos_gitlab I'm interested, where did you place your navwalkers? I've just been putting them in the helpers directory under app\WordPress\Navwalkers namespace. Although that works fine, it may not be the cleanest way, so I'm curious.
    Luc D
    @LucArthos_gitlab
    @tomkeysers just as Atanas said: I created my Walker in /src/Walkers/CustomWalker.php and then included it by calling it new \MyApp\Walkers\CustomWalker()
    Tom K.
    @tomkeysers
    @LucArthos_gitlab Alright!