Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View Components install problem #151

Open
laze opened this issue Dec 4, 2024 · 1 comment
Open

View Components install problem #151

laze opened this issue Dec 4, 2024 · 1 comment

Comments

@laze
Copy link

laze commented Dec 4, 2024

Steps to reproduce:

  1. Create a package with Spatie Package Tools, like below.
  2. Add a view package, and use hasViewPackage() method.
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelPackageTools\Package;

class AwesomePackageServiceProvider extends PackageServiceProvider
{
  public function configurePackage(Package $package): void
    $package
      ->hasViewComponent('nitrogen', Menu::class)
  ...
  • If you put the View Component's PHP part to src/View/Components, then the publish command will not run, it will say, the PHP file is missing from src/Components. If you move the folder, and the file to this location, publish will not run, but Laravel will say, View Component is missing from View/Components folder. So the quick and dirty solution is using PHP file in both location, but it's not okay, double to maintain.

The issue is here, the word 'View' is missing from the path. If I put the word "View" there, the publish command will work without any issue, and of course Laravel too...

// \vendor\spatie\laravel-package-tools\src\PackageServiceProvider.php:138

        if (count($this->package->viewComponents)) {
            $this->publishes([
                $this->package->basePath('/     View      /Components') => base_path("app/View/Components/vendor/{$this->package->shortName()}"),
            ], "{$this->package->name}-components");
        }
@laze
Copy link
Author

laze commented Dec 4, 2024

Github missed the link:

$this->package->basePath('/Components') => base_path("app/View/Components/vendor/{$this->package->shortName()}"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant