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•2y 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•2y 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•2y ago
the publish is fine it's the same as the spatie/laravel-package-tools nothing in that has changed
datarecall
datarecallOP•2y ago
what would cause the routes to work?
Lara Zeus
Lara Zeus•2y 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•2y 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•2y ago
what in your web.php?
datarecall
datarecallOP•2y 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•2y 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•2y 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•2y ago
can you access the resources in /admin?
datarecall
datarecallOP•2y ago
datarecall
datarecallOP•2y ago
resource does not show up its almost like its not loading at all
Lara Zeus
Lara Zeus•2y ago
did you add the plugin to your adminPanelProvider?
Lara Zeus
Lara Zeus•2y ago
GitHub
plugin-skeleton/src/SkeletonPlugin.php at 3.x Ā· filamentphp/plugin-...
A package skeleton for developing Filament plugins. - filamentphp/plugin-skeleton
datarecall
datarecallOP•2y 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•2y 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•2y 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•2y 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•2y ago
yes
"illusive-ch/blog": "@dev",
"illusive-ch/blog": "@dev",
Lara Zeus
Lara Zeus•2y ago
composer update?
datarecall
datarecallOP•2y 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•2y ago
this is the way the AdminPanelProvider is in your testing app
datarecall
datarecallOP•2y ago
yes
Thijmen
Thijmen•2y ago
BlogPlugin::make()
Lara Zeus
Lara Zeus•2y ago
nice catch šŸ™‚
datarecall
datarecallOP•2y 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•2y ago
What imports are you using? Do you see the resource now in the menu?
datarecall
datarecallOP•2y ago
one sec updating the imports
Lara Zeus
Lara Zeus•2y ago
I guess you missing an import
Thijmen
Thijmen•2y ago
I've never seen Filament\Resources\Form classes
Lara Zeus
Lara Zeus•2y ago
from v2
Thijmen
Thijmen•2y ago
Maybe Filament\Forms\Form now?
Lara Zeus
Lara Zeus•2y ago
yup
datarecall
datarecallOP•2y 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•2y 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•2y 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•2y ago
My plugin form is this: public static function form(Form $form): Form
datarecall
datarecallOP•2y ago
ahhh nm its the same issue bad import
Thijmen
Thijmen•2y ago
Yeah i guess replace most of the Resources to Forms
Lara Zeus
Lara Zeus•2y ago
there is many method signature changed
datarecall
datarecallOP•2y ago
awesome thank you both, i think it got it all working now
Thijmen
Thijmen•2y ago
Great, good luck!
Lara Zeus
Lara Zeus•2y ago
congrats

Did you find this page helpful?