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

Cant access elfinder after fresh install #191

Closed
reeslo opened this issue Oct 19, 2016 · 21 comments
Closed

Cant access elfinder after fresh install #191

reeslo opened this issue Oct 19, 2016 · 21 comments

Comments

@reeslo
Copy link
Contributor

reeslo commented Oct 19, 2016

Laravel return only an 404 error, I do all steps.

@reeslo
Copy link
Contributor Author

reeslo commented Oct 20, 2016

config('elfinder.route.prefix') return /elfinder

but elfinder.php configuration has :

    'route' => [
        'prefix'     => config('backpack.base.route_prefix').'/elfinder',
        'middleware' => ['web', 'auth'], //Set to null to disable middleware filter
    ],

@tabacitu
Copy link
Member

Hi @reeslo ,

I've just installed a fresh copy to test it and it works perfectly for me.
(1) Are you sure you've followed all the installation steps?
(2) Did you install the demo project or manually the Base and CRUD packages?
(3) Do you mean elfinder is not working inside ckeditor/etc or stand-alone, at http://project-name/admin/elfinder?

Cheers!

@reeslo
Copy link
Contributor Author

reeslo commented Oct 21, 2016

I've installed too time with composer after base package.

For the two installations elfinder.route.prefix dont return the complete route Idk why the backpack.base.route_prefix are not parsed in the config file. I set admin path manually. I am at work monday if you want more investigations :)

@reeslo
Copy link
Contributor Author

reeslo commented Oct 21, 2016

for the steps I do all listed like readme.io base, crud, ..., ...

@reeslo
Copy link
Contributor Author

reeslo commented Oct 21, 2016

sorry for multiple messages. The issue was the route not reconized

@tabacitu
Copy link
Member

What about your base config file, then, in app/config/backpack/base.php? It should contain something like:

    /*
    |--------------------------------------------------------------------------
    | Routing
    |--------------------------------------------------------------------------
    */

    // The prefix used in all base routes (the 'admin' in admin/dashboard)
    'route_prefix' => 'admin',

    // Set this to false if you would like to use your own AuthController and PasswordController
    // (you then need to setup your auth routes manually in your routes.php file)
    'setup_auth_routes' => true,

    // Set this to false if you would like to skip adding the dashboard routes
    // (you then need to overwrite the login route on your AuthController)
    'setup_dashboard_routes' => true,

    /*
    |--------------------------------------------------------------------------
    | User Model
    |--------------------------------------------------------------------------
    */

    // Fully qualified namespace of the User model
    'user_model_fqn' => '\App\User',

I'm more interested in the route_prefix variable. If it's not valid, a 404 error might be shown when trying to access elfinder.

@tabacitu
Copy link
Member

Or if you changed the value in the config file, take a look at sidebar.blade.php - it may contain the link to the elfinder section using the url('admin/elfinder') instead of the correct url(config('backpack.base.route_prefix', 'admin') . '/elfinder'). This mistake was in an old documentation file, you might have used that.

@reeslo
Copy link
Contributor Author

reeslo commented Oct 22, 2016

I've changed the route_prefix value, I have noted difference for adding url in blade template I use url(config(....).'elfinder'). I look monday at work if I Can drop you more informations

@reeslo
Copy link
Contributor Author

reeslo commented Oct 22, 2016

I re-do same steps with a fresh laravel install same issue,

I've screenrecorded to show you, config/elfinder.php does not add the config('backpack.base.route_prefix') value.
https://framadrop.org/r/0lSy-_rIR9#ijQCjROnp/AxdaVkPN3VZKF0k5imoJYYf6cU8gGHdoI=

I can access to elfinder http://localhost/public/elfinder like in screenshot
forget

@tabacitu
Copy link
Member

This is very very weird. Just tried it again, changed the admin prefix and it does work for me. And I used exactly your settings. Video here. So the problem in your case seems that elfinder does not register the modification you made to the elfinder config file.

Question: if you edit something else in config/elfinder.php, does the modification register?

@reeslo
Copy link
Contributor Author

reeslo commented Oct 23, 2016

yes it work if I set manually the prefix in config/elfinder.php

@reeslo
Copy link
Contributor Author

reeslo commented Oct 28, 2016

I was looking to find why..
Its very strange elfinder.php can't read backpack.base but other config file too test/test.php.
I copy the forlder to backpack2 and this work...
image

dd(\Config::all());

capture d ecran 2016-10-28 a 19 27 38-fullpage

I changed all permission files to 777 for test, same !

php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies

@tabacitu
Copy link
Member

This is weird. Are the Backpack service providers loaded at the END of your config/app.php's providers array? After everything else? Here are mine:

/*
         * Backpack Service Providers...
         */
        Backpack\Base\BaseServiceProvider::class,
        Backpack\CRUD\CrudServiceProvider::class,
        Backpack\NewsCRUD\NewsCRUDServiceProvider::class,
        Backpack\LangFileManager\LangFileManagerServiceProvider::class,
        Spatie\Backup\BackupServiceProvider::class,
        Backpack\BackupManager\BackupManagerServiceProvider::class,
        Backpack\LogManager\LogManagerServiceProvider::class,
        Backpack\Settings\SettingsServiceProvider::class,
        Backpack\PageManager\PageManagerServiceProvider::class,
        Backpack\PermissionManager\PermissionManagerServiceProvider::class,
        Backpack\MenuCRUD\MenuCRUDServiceProvider::class,
        Backpack\LangFileManager\LangFileManagerServiceProvider::class,

@reeslo
Copy link
Contributor Author

reeslo commented Oct 31, 2016

:(

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,

        /*
         * Package Service Providers...
         */


        /*
        * Backpack Service Providers...
        */
        Backpack\Base\BaseServiceProvider::class,
        Backpack\CRUD\CrudServiceProvider::class,


        //

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],

@tabacitu
Copy link
Member

tabacitu commented Nov 9, 2016

Hi @reeslo , figured this out yet?

Cheers!

@reeslo
Copy link
Contributor Author

reeslo commented Nov 9, 2016

Hi, sorry I don't understand :x

@zschuessler
Copy link

Simple solution is to update the CrudServiceProvider.php file on the register method to set the configuration dynamically:

public function register()
{
    \Config::set(
        'elfinder.route.prefix',
        \Config::get('backpack.base.route_prefix') . '/elfinder'
    );

(I'm open to suggestions on if this is the best place, architecturally, to override the elfinder config.)

Why This Works

In Laravel 4 it appears it was once possible to access variables in the configuration files. This is no longer the case in Laravel 5, by design. Configuration files are loaded too early in the bootstrapping process to access the configuration of another config file (properly, anyway).

The new solution is to either use .env files (which doesn't apply here) , to set dynamic values in your service provider (as I did above), or to use middleware.

On a last note, I hard-coded the "elfinder" path as suffix to the dynamic path. You might want to instead use the default path the elfinder library uses (which is just /elfinder)

@OwenMelbz
Copy link
Contributor

as @zschuessler has provided a workaround, I'll close this off now, feel free to further discuss, its been added to the list over #285 for future reference

@tabacitu
Copy link
Member

tabacitu commented Dec 5, 2016

@zschuessler , I tried again and again and I wasn't able to replicate this issue. The config value gets registered for me. I think we'll implement a solution blindly in this case, because I want you guys to stop having this issue.

  1. Wouldn't your solution overwrite the default config value, if that did get set? I'm think we should wrap it in an if statement:
        // map the elfinder prefix
        if (!\Config::get('elfinder.route.prefix')) {
            \Config::set('elfinder.route.prefix', \Config::get('backpack.base.route_prefix') . '/elfinder');
        }

Can you please confirm this solution fixes it for you, in CrudServiceProvider::register()?

  1. Can you please give me more details about your system, so I can try to match it entirely, one last time?
  • Laravel version
  • Backpack\Base version
  • Backpack\CRUD version
  • Operating System
  • PHP version
  • Apache\Nginx version

Thank a lot, cheers!

@zschuessler
Copy link

@tabacitu #1 - correct on overriding the config, posted that for an example. Sorry for confusion!

#2 - Sure:

Larvel: 5.3.*
Backpack\Base: dev-master
Backpack\CRUD: dev-master
OS: LinuxMint 17
PHP: 7.0.8
Apache: 1.4.8 (Ubuntu)

@tabacitu
Copy link
Member

Ok, just pushed an update that should fix it, using the method above. A composer update should fix it for you guys. If not, please let me know. Cheers!

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

4 participants