F
Filamentā€¢16mo ago
datarecall

Personal Plugin v3 Upgrade not showing up

I have a personal blog plugin for filament, here is my service provider. From the documentation it looks like we can still use spatie package tools here is my service provider
<?php

namespace Illusive\Blog;

//use Filament\PluginServiceProvider;
use Illusive\Blog\Commands\CreatePostLowestCategoryCommand;
use Illusive\Blog\Commands\InstallCommand;
use Illusive\Blog\Middleware\IncrementPostViewsMiddleware;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class BlogServiceProvider extends PackageServiceProvider
{
protected array $resources = [
AuthorResource::class,
CategoryResource::class,
PostResource::class,
];

public function configurePackage(Package $package): void
{
$package
->name('filament-blog')
->hasConfigFile()
->hasTranslations()
->hasCommand(InstallCommand::class)
->hasCommand(CreatePostLowestCategoryCommand::class)
->hasRoute('web')
->hasMigration('create_filament_blog_tables')
->hasMigration('update_blog_tables_2023-08-2');

$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');

$this->app['router']->aliasMiddleware('increment.views', IncrementPostViewsMiddleware::class);
}
}
<?php

namespace Illusive\Blog;

//use Filament\PluginServiceProvider;
use Illusive\Blog\Commands\CreatePostLowestCategoryCommand;
use Illusive\Blog\Commands\InstallCommand;
use Illusive\Blog\Middleware\IncrementPostViewsMiddleware;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class BlogServiceProvider extends PackageServiceProvider
{
protected array $resources = [
AuthorResource::class,
CategoryResource::class,
PostResource::class,
];

public function configurePackage(Package $package): void
{
$package
->name('filament-blog')
->hasConfigFile()
->hasTranslations()
->hasCommand(InstallCommand::class)
->hasCommand(CreatePostLowestCategoryCommand::class)
->hasRoute('web')
->hasMigration('create_filament_blog_tables')
->hasMigration('update_blog_tables_2023-08-2');

$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');

$this->app['router']->aliasMiddleware('increment.views', IncrementPostViewsMiddleware::class);
}
}
From what I can see its not registering the routes so may not be running the service provider ?
45 Replies
Lara Zeus
Lara Zeusā€¢16mo ago
GitHub
GitHub - filamentphp/plugin-skeleton: A package skeleton for develo...
A package skeleton for developing Filament plugins. - GitHub - filamentphp/plugin-skeleton: A package skeleton for developing Filament plugins.
datarecall
datarecallOPā€¢16mo ago
ok Ill modify my service provider like the skeleton one how would I convert
$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');
To the new syntax
Lara Zeus
Lara Zeusā€¢16mo ago
the publish is fine it's the same as the spatie/laravel-package-tools nothing in that has changed
datarecall
datarecallOPā€¢16mo ago
what would cause the routes to work?
Lara Zeus
Lara Zeusā€¢16mo ago
make sure the service provider is in the composer autoload is it in the artisan route:list? any errors other than 404? make sure you register the routes as explained in spatie/laravel-package-tools
datarecall
datarecallOPā€¢16mo ago
route:list is not showing the added routes
->hasRoute('web')
->hasRoute('web')
is what i am using in the configurePackage
Lara Zeus
Lara Zeusā€¢16mo ago
what in your web.php?
datarecall
datarecallOPā€¢16mo ago
<?php

use Illuminate\Support\Facades\Route;
use Illusive\Blog\Http\Controllers\PostController;
use Illusive\Blog\Http\Controllers\TagController;

Route::middleware(['web', 'increment.views'])->group(function () {
Route::prefix('blog')->group(function () {
Route::resource('post', PostController::class)->parameters(['post' => 'slug']);
Route::resource('tag', TagController::class)->parameters(['tag' => 'slug']);
});
});
<?php

use Illuminate\Support\Facades\Route;
use Illusive\Blog\Http\Controllers\PostController;
use Illusive\Blog\Http\Controllers\TagController;

Route::middleware(['web', 'increment.views'])->group(function () {
Route::prefix('blog')->group(function () {
Route::resource('post', PostController::class)->parameters(['post' => 'slug']);
Route::resource('tag', TagController::class)->parameters(['tag' => 'slug']);
});
});
it works fine in 2.x just not 3.x
Lara Zeus
Lara Zeusā€¢16mo ago
if you if you can share the ServiceProvider do you have
"extra": {
"laravel": {
"providers": [
"LaraZeus\\Bolt\\BoltServiceProvider"
]
}
},
"extra": {
"laravel": {
"providers": [
"LaraZeus\\Bolt\\BoltServiceProvider"
]
}
},
in your composer?
datarecall
datarecallOPā€¢16mo ago
"extra": {
"laravel": {
"providers": [
"Illusive\\Blog\\BlogServiceProvider"
]
},
"npm": {
"@heroicons/vue": "^2.0.13"
}
},
"extra": {
"laravel": {
"providers": [
"Illusive\\Blog\\BlogServiceProvider"
]
},
"npm": {
"@heroicons/vue": "^2.0.13"
}
},
And the files for building the package are located in /packages/filement-blog
<?php

namespace Illusive\Blog;

use Illusive\Blog\Commands\CreatePostLowestCategoryCommand;
use Illusive\Blog\Commands\InstallCommand;
use Illusive\Blog\Middleware\IncrementPostViewsMiddleware;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class BlogServiceProvider extends PackageServiceProvider
{
protected array $resources = [
AuthorResource::class,
CategoryResource::class,
PostResource::class,
];

public function configurePackage(Package $package): void
{
$package
->name('filament-blog')
->hasConfigFile()
->hasTranslations()
->hasCommand(InstallCommand::class)
->hasCommand(CreatePostLowestCategoryCommand::class)
->hasRoute('web')
->hasMigration('create_filament_blog_tables')
->hasMigration('update_blog_tables_2023-08-2');

$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');

$this->app['router']->aliasMiddleware('increment.views', IncrementPostViewsMiddleware::class);
}
}
<?php

namespace Illusive\Blog;

use Illusive\Blog\Commands\CreatePostLowestCategoryCommand;
use Illusive\Blog\Commands\InstallCommand;
use Illusive\Blog\Middleware\IncrementPostViewsMiddleware;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class BlogServiceProvider extends PackageServiceProvider
{
protected array $resources = [
AuthorResource::class,
CategoryResource::class,
PostResource::class,
];

public function configurePackage(Package $package): void
{
$package
->name('filament-blog')
->hasConfigFile()
->hasTranslations()
->hasCommand(InstallCommand::class)
->hasCommand(CreatePostLowestCategoryCommand::class)
->hasRoute('web')
->hasMigration('create_filament_blog_tables')
->hasMigration('update_blog_tables_2023-08-2');

$this->publishes([__DIR__.'/../resources/js/Pages' => resource_path('js/Pages')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogPagination.vue' => resource_path('js/Components/BlogPagination.vue')], 'vue-blog-pages');
$this->publishes([__DIR__.'/../resources/js/BlogContentContainer.vue' => resource_path('js/Components/BlogContentContainer.vue')], 'vue-blog-pages');

$this->app['router']->aliasMiddleware('increment.views', IncrementPostViewsMiddleware::class);
}
}
Lara Zeus
Lara Zeusā€¢16mo ago
can you access the resources in /admin?
datarecall
datarecallOPā€¢16mo ago
datarecall
datarecallOPā€¢16mo ago
resource does not show up its almost like its not loading at all
Lara Zeus
Lara Zeusā€¢16mo ago
did you add the plugin to your adminPanelProvider?
Lara Zeus
Lara Zeusā€¢16mo ago
GitHub
plugin-skeleton/src/SkeletonPlugin.php at 3.x Ā· filamentphp/plugin-...
A package skeleton for developing Filament plugins. - filamentphp/plugin-skeleton
datarecall
datarecallOPā€¢16mo ago
then you would add the plugin to :
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => Color::Amber,
])
->plugins([
BlogPlugin::class
])
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => Color::Amber,
])
->plugins([
BlogPlugin::class
])
Lara Zeus
Lara Zeusā€¢16mo ago
for the resources to show up in the admin, you gonna need a pluginClass and register it in the admin panel provider but the route issue I am not sure, it should be registered since you have a serviceProvider auto loaded
datarecall
datarecallOPā€¢16mo ago
so blogPlugin should look something like this
<?php

namespace Illusive\Blog;

use Filament\Contracts\Plugin;
use Filament\Panel;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;

class BlogPlugin implements Plugin
{
public function getId(): string
{
return 'blog';
}

public function register(Panel $panel): void
{
$panel
->resources([
AuthorResource::class,
CategoryResource::class,
PostResource::class,
]);
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}

public static function get(): static
{
/** @var static $plugin */
$plugin = filament(app(static::class)->getId());

return $plugin;
}
}
<?php

namespace Illusive\Blog;

use Filament\Contracts\Plugin;
use Filament\Panel;
use Illusive\Blog\Resources\AuthorResource;
use Illusive\Blog\Resources\CategoryResource;
use Illusive\Blog\Resources\PostResource;

class BlogPlugin implements Plugin
{
public function getId(): string
{
return 'blog';
}

public function register(Panel $panel): void
{
$panel
->resources([
AuthorResource::class,
CategoryResource::class,
PostResource::class,
]);
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}

public static function get(): static
{
/** @var static $plugin */
$plugin = filament(app(static::class)->getId());

return $plugin;
}
}
Lara Zeus
Lara Zeusā€¢16mo ago
did you require the package to the composer of the main app you testing?? "Illusive/blog": "...", šŸ™‚ I dont have any other solutions to think of
datarecall
datarecallOPā€¢16mo ago
yes
"illusive-ch/blog": "@dev",
"illusive-ch/blog": "@dev",
Lara Zeus
Lara Zeusā€¢16mo ago
composer update?
datarecall
datarecallOPā€¢16mo ago
how do you add the plugin to the adminserviceprovider I think that might be the step I am missing AdminPanelProvider*
Lara Zeus
Lara Zeusā€¢16mo ago
this is the way the AdminPanelProvider is in your testing app
datarecall
datarecallOPā€¢16mo ago
yes
Thijmen
Thijmenā€¢16mo ago
BlogPlugin::make()
Lara Zeus
Lara Zeusā€¢16mo ago
nice catch šŸ™‚
datarecall
datarecallOPā€¢16mo ago
ok making headway we got errors now, I am guessing Form changed in v3
Could not check compatibility between Illusive\Blog\Resources\AuthorResource::form(Filament\Resources\Form $form): Filament\Resources\Form and Filament\Resources\Resource::form(Filament\Forms\Form $form): Filament\Forms\Form, because class Filament\Resources\Form is not available
Could not check compatibility between Illusive\Blog\Resources\AuthorResource::form(Filament\Resources\Form $form): Filament\Resources\Form and Filament\Resources\Resource::form(Filament\Forms\Form $form): Filament\Forms\Form, because class Filament\Resources\Form is not available
yup
Thijmen
Thijmenā€¢16mo ago
What imports are you using? Do you see the resource now in the menu?
datarecall
datarecallOPā€¢16mo ago
one sec updating the imports
Lara Zeus
Lara Zeusā€¢16mo ago
I guess you missing an import
Thijmen
Thijmenā€¢16mo ago
I've never seen Filament\Resources\Form classes
Lara Zeus
Lara Zeusā€¢16mo ago
from v2
Thijmen
Thijmenā€¢16mo ago
Maybe Filament\Forms\Form now?
Lara Zeus
Lara Zeusā€¢16mo ago
yup
datarecall
datarecallOPā€¢16mo ago
so the form methods should not be static it looks like either
public static function form(Form $form): Form
public static function form(Form $form): Form
Thijmen
Thijmenā€¢16mo ago
Good to remember that the standard method to register a plugin is: new BlogPlugin() With the make function you added you need to do BlogPlugin::make() That is why it didn't work
datarecall
datarecallOPā€¢16mo ago
Cannot make non static method Filament\Resources\RelationManagers\RelationManager::form() static in class Illusive\Blog\Resources\CategoryResource\RelationManagers\PostsRelationManager
Cannot make non static method Filament\Resources\RelationManagers\RelationManager::form() static in class Illusive\Blog\Resources\CategoryResource\RelationManagers\PostsRelationManager
Thijmen
Thijmenā€¢16mo ago
My plugin form is this: public static function form(Form $form): Form
datarecall
datarecallOPā€¢16mo ago
ahhh nm its the same issue bad import
Thijmen
Thijmenā€¢16mo ago
Yeah i guess replace most of the Resources to Forms
Lara Zeus
Lara Zeusā€¢16mo ago
there is many method signature changed
datarecall
datarecallOPā€¢16mo ago
awesome thank you both, i think it got it all working now
Thijmen
Thijmenā€¢16mo ago
Great, good luck!
Lara Zeus
Lara Zeusā€¢16mo ago
congrats
Want results from more Discord servers?
Add your server