No hint path defined for [xxx]

14,568

Solution 1

I think report is your package name,

Step 1: You must specify the package name inside the service provider

$this->loadViewsFrom(__DIR__.'/views', 'report'); 

Step 2: If you want to load the view

return view('packageName::Email.testmail'); //packageName is report, the actual path to my view is package/report/src/views/Email/testmail.blade.php

Solution 2

You need to add the package' service provider in cofing/app.php

Solution 3

I solved the error No hint path defined for [view] by putting the following code snippet on my service provider boot method of my package:

$this->loadViewsFrom(__DIR__.'/views', 'home');

Where home is my view file home.blade.php. As I am Laravel beginner, maybe in package builded type of coding in need to give the path of view files inside service provider.

Share:
14,568
stUrb
Author by

stUrb

Updated on June 15, 2022

Comments

  • stUrb
    stUrb almost 2 years

    I'm trying to link in my package to a view also in the same package.
    This is the file structure:

    /report/src
    /report/src/ReportServiceProvider.php
    /report/src/views/test.blade.php
    /report/src/SomeClass.php
    

    In my ReportServiceProvider.php I specify the directory where the views should be loading from (like specified here):

    public function boot()
    {
        $this->loadViewsFrom(__DIR__.'/views', 'reports');
    }
    

    With the 'hint' reports, so I should be able to access them with view('reports::test')

    Off course I add my ServiceProvider to /config/app.php's providers array like so:

    ....
    Vendor\Report\ReportServiceProvider::class,
    ....
    

    I load my package in composer as follows:

    "autoload": {
      ....
      "psr-4": {
         "App\\": "app/",
         "Vendor\\Report\\": "packages/vendor/report/src"
      }
      ...
     }
    

    But when I use the view('reports::test') in SomeClass.php i get the following error:

    No hint path defined for [reports]

    So somehow it cannot find the reports hint.... What am I missing here?

    • Ian
      Ian almost 7 years
      Can you dump __DIR__ within the server provider?
    • stUrb
      stUrb almost 7 years
      Hmmm, die('something') does not produce a die, application just gets loaded.... so the serviceprovider might not be loading?
    • Ian
      Ian almost 7 years
      Indeed that is correct. Just to make sure, create a register method in your service provider and then dump something, see if that shows up, otherwise it's not loading your provider, could try a composer dump-autoload if you think the path to the provider is correct?
    • stUrb
      stUrb almost 7 years
      I must be missing something.... I put defer=false to let it always load; in register() a simple die('hello'); but nothing happens :(
    • Ian
      Ian almost 7 years
      You also shouldn't need to use the autoload section for custom packages, assuming there are in the vendor directory.
    • stUrb
      stUrb almost 7 years
      They are not in the vendor directory, so that's why I'm loading them via the psr-4 method :)
    • Ian
      Ian almost 7 years
      Ok spitballing here, in the register method of your service provider, try using the facade View. View::addNamespace('reports', [path(s)])
    • huuuk
      huuuk almost 7 years
      Sorry, but I think that your decision to plase views folder in src was inappropriate. Try to move it from src.
    • Ian
      Ian almost 7 years
      @huuuk where he puts them doesn't matter as long as they are loaded correctly.
    • huuuk
      huuuk almost 7 years
      @lan I think that cause of the issue is They are not in the vendor directory, so that's why I'm loading them via the psr-4 method :)
  • Anand Singh
    Anand Singh over 2 years
    This worked! Add VoyagerThemes\VoyagerThemesServiceProvider::class, to be precise.