Solved
cyberekklesia

Oct 8th, 2022 06:51 PM

Any change or workaround suggestions to the following?

Here is the story:

  1. php artisan optimize gives error to Admin (under profile). [Route [voyager.theme.index] not defined.] This is fixed with php artisan route:clear.

  2. After installing laravel-forum (Branch 5.0) (https://github.com/Team-Tea-Time/laravel-forum) blog categories and post gives 404 | NOT FOUND. This is fixed with php artisan optimize.

Great... What now? At this point, php artisan optimize breaks Admin, and php artisan route:clear breaks blog categories & posts.

I'm using Wampserver 3.2.6 - 64bit, Apache 2.4.51, PHP 8.1, MySQL 5.7.36, MariaDB 10.6.5.

Thank you

bobbyiliev

Oct 9th, 2022 04:20 AM

Hi there,

It sounds like that the laravel-forum package might be having some overlapping routes with Voyager, what you could do is make sure that the laravel-forum routes have a prefix so that they don't overlap.

Are you using Wave or just a plain Laravel app with Voyager? I could try to replicate this on my end too.

Best,

Bobby

cyberekklesia

Oct 9th, 2022 05:00 AM

Hello Bobby.

Thank you for you answer. I'm using Wave. I renamed the forum prefix (config) but it didn't fix the problem. So, I put it back.

If you can replicate the problem it would be helpful.

Thank you

bobbyiliev

Oct 9th, 2022 08:58 AM

Hey there,

I've just installed Wave on a fresh new Ubuntu server and then installed the Laravel forum package. It seems like everything is working as expected including the php artisan optimize command and the categories routes.

Can you confirm what version of wave are you using and is it a new installation or an existing app that you have?

For me after the default installation even the default forum routes do not interfere with the Wave routes.

cyberekklesia

Oct 9th, 2022 10:14 AM

Just did a brand new installation.

Process & result:

  1. Wave: After installation was completed, no command was executed, nor required. Blog and Admin worked just fine.
  2. Forum: After installation was completed, php artisan optimize was required. Otherwise, forum & blog won't work. This command broke Admin. After executing route:clear, Admin was fixed but blog broken. Forum kept working.

This is strange...

On my original project: It's a new installation too and forum the very first package installed other than the wave requirements. I did remove the forum and reinstalled everything again but errors persists. There is no other modification than User profile (globals).

Note: I'm using WAMP Server. Even on a fresh Wave installation php artisan optimize doesn't work properly. Command will break Admin.

In both scenarios the error are the same.

bobbyiliev

Oct 10th, 2022 01:59 AM

Hi there,

What is the exact error that you get for the admin route after running the optimize command? If it is just a 500 error, can you check the logs as well and see the complete error in there too?

I don't have a windows laptop on hand, but it all seems to be working fine with a new LEMP server:

https://marketplace.digitalocean.com/apps/laravel

cyberekklesia

Oct 10th, 2022 08:17 AM

The commands doesn't give any errors perse. The errors shows when visiting Admin or Blog. After running optimize, Admin shows Route [voyager.theme.index] not defined. This error clears with route:clear. Then blog show errors.

Here is the Admin link error - let me know if you want to see the stacktrace:

[2022-10-10 15:06:55] local.ERROR: Route [voyager.theme.index] not defined. {"view":{"view":"C:\wamp64\www\WaveDev\vendor\tcg\voyager\resources\views\dashboard\sidebar.blade.php","data":{"theme":"<pre class=sf-dump id=sf-dump-1590806515 data-indent-pad=" ">DevDojo\Themes\Models\Theme {#1593 #<span class=sf-dump-protected title="Protected property">connection: "<span class=sf-dump-str title="5 characters">mysql" #<span class=sf-dump-protected title="Protected property">table: "<span class=sf-dump-str title="6 characters">themes" #<span class=sf-dump-protected title="Protected property">primaryKey: "<span class=sf-dump-str title="2 characters">id" #<span class=sf-dump-protected title="Protected property">keyType: "<span class=sf-dump-str title="3 characters">int" +<span class=sf-dump-public title="Public property">incrementing: true #<span class=sf-dump-protected title="Protected property">with: [] #<span class=sf-dump-protected title="Protected property">withCount: [] +<span class=sf-dump-public title="Public property">preventsLazyLoading: false #<span class=sf-dump-protected title="Protected property">perPage: 15 +<span class=sf-dump-public title="Public property">exists: true +<span class=sf-dump-public title="Public property">wasRecentlyCreated: false #<span class=sf-dump-protected title="Protected property">escapeWhenCastingToString: false #<span class=sf-dump-protected title="Protected property">attributes: array:7 [ "id" => 1 "name" => "<span class=sf-dump-str title="14 characters">Tailwind Theme" "folder" => "<span class=sf-dump-str title="8 characters">tailwind" "active" => 1 "version" => "<span class=sf-dump-str title="3 characters">1.1" "created_at" => "<span class=sf-dump-str title="19 characters">2020-08-23 08:06:45" "updated_at" => "<span class=sf-dump-str title="19 characters">2022-10-03 01:16:25" ] #<span class=sf-dump-protected title="Protected property">original: array:7 [ "id" => 1 "name" => "<span class=sf-dump-str title="14 characters">Tailwind Theme" "folder" => "<span class=sf-dump-str title="8 characters">tailwind" "active" => 1 "version" => "<span class=sf-dump-str title="3 characters">1.1" "created_at" => "<span class=sf-dump-str title="19 characters">2020-08-23 08:06:45" "updated_at" => "<span class=sf-dump-str title="19 characters">2022-10-03 01:16:25" ] #<span class=sf-dump-protected title="Protected property">changes: [] #<span class=sf-dump-protected title="Protected property">casts: [] #<span class=sf-dump-protected title="Protected property">classCastCache: [] #<span class=sf-dump-protected title="Protected property">attributeCastCache: [] #<span class=sf-dump-protected title="Protected property">dates: [] #<span class=sf-dump-protected title="Protected property">dateFormat: null #<span class=sf-dump-protected title="Protected property">appends: [] #<span class=sf-dump-protected title="Protected property">dispatchesEvents: [] #<span class=sf-dump-protected title="Protected property">observables: [] #<span class=sf-dump-protected title="Protected property">relations: [] #<span class=sf-dump-protected title="Protected property">touches: [] +<span class=sf-dump-public title="Public property">timestamps: true #<span class=sf-dump-protected title="Protected property">hidden: [] #<span class=sf-dump-protected title="Protected property">visible: [] #<span class=sf-dump-protected title="Protected property">fillable: array:3 [ 0 => "<span class=sf-dump-str title="4 characters">name" 1 => "<span class=sf-dump-str title="6 characters">folder" 2 => "<span class=sf-dump-str title="7 characters">version" ] #<span class=sf-dump-protected title="Protected property">guarded: array:1 [ 0 => "*" ] } <script>Sfdump("sf-dump-1590806515", {"maxDepth":3,"maxStringLength":160})</script> ","errors":"<pre class=sf-dump id=sf-dump-1929591624 data-indent-pad=" ">Illuminate\Support\ViewErrorBag {#1547 #<span class=sf-dump-protected title="Protected property">bags: [] } <script>Sfdump("sf-dump-1929591624", {"maxDepth":3,"maxStringLength":160})</script> ","alerts":"<pre class=sf-dump id=sf-dump-1748507104 data-indent-pad=" ">[] <script>Sfdump("sf-dump-1748507104", {"maxDepth":3,"maxStringLength":160})</script> ","google_analytics_client_id":"<pre class=sf-dump id=sf-dump-1015435341 data-indent-pad=" ">null <script>Sfdump("sf-dump-1015435341", {"maxDepth":3,"maxStringLength":160})</script> ","admin_favicon":"<pre class=sf-dump id=sf-dump-1248853137 data-indent-pad=" ">"" <script>Sfdump("sf-dump-1248853137", {"maxDepth":3,"maxStringLength":160})</script> ","__currentLoopData":"<pre class=sf-dump id=sf-dump-356524936 data-indent-pad=" ">array:1 [ 0 => "<span class=sf-dump-str title="19 characters">/wave/css/admin.css" ] <script>Sfdump("sf-dump-356524936", {"maxDepth":3,"maxStringLength":160})</script> ","css":"<pre class=sf-dump id=sf-dump-281791546 data-indent-pad=" ">"<span class=sf-dump-str title="19 characters">/wave/css/admin.css" <script>Sfdump("sf-dump-281791546", {"maxDepth":3,"maxStringLength":160})</script> ","loop":"<pre class=sf-dump id=sf-dump-363063973 data-indent-pad=" ">null <script>Sfdump("sf-dump-363063973", {"maxDepth":3,"maxStringLength":160})</script> ","admin_loader_img":"<pre class=sf-dump id=sf-dump-1487962920 data-indent-pad=" ">"" <script>Sfdump("sf-dump-1487962920", {"maxDepth":3,"maxStringLength":160})</script> ","user_avatar":"<pre class=sf-dump id=sf-dump-1844067612 data-indent-pad=" ">"<span class=sf-dump-str title="65 characters">http://wavedev/storage/users/October2022/yak7NPjP0qNk4Q0fNsmt.png" <script>Sfdump("sf-dump-1844067612", {"maxDepth":3,"maxStringLength":160})</script> "}},"userId":1,"exception":"[object] (Spatie\LaravelIgnition\Exceptions\ViewException(code: 0): Route [voyager.theme.index] not defined. at C:\wamp64\www\WaveDev\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php:467)

bobbyiliev

Oct 11th, 2022 02:21 AM

Best Answer

Hi there,

I was actually finally able to reproduce the problem!

A quick fix would be to edit the vendor/devdojo/themes/src/ThemesServiceProvider.php file and in the register() method, comment the first if statement, eg:

    public function register()
    {
        //if (request()->is(config('voyager.prefix')) || request()->is(config('voyager.prefix').'/*')) {
            $this->addThemesTable();

            app(Dispatcher::class)->listen('voyager.menu.display', function ($menu) {
                $this->addThemeMenuItem($menu);
            });

            app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {
                $this->addThemeRoutes($router);
            });
        //}

As a permanent fix, I'll try to submit a PR for that themes package to implement that specific change!

Thank you for reporting the problem!

Report
1
bobbyiliev

Oct 11th, 2022 02:27 AM

As a reference, here is a link to the PR:

https://github.com/thedevdojo/themes/pull/7

I just need a review before merging this and bumping up the package version!

Report
1
cyberekklesia

Oct 11th, 2022 06:48 AM

Yes! That fixed the issue.

Thank you for your help.

Report
1
bobbyiliev

Oct 11th, 2022 09:42 AM

No problem! Happy to hear that it is all working now!