HansSchouten / Laravel-Pagebuilder

A drag and drop pagebuilder to manage pages in any Laravel project
https://www.phpagebuilder.com
MIT License
800 stars 184 forks source link

Problem with Docker #89

Open AnastasiaKremenetskaya opened 3 years ago

AnastasiaKremenetskaya commented 3 years ago

When using docker router not working as it should work. And shows Asset not found to all assets in package.

Снимок экрана 2021-02-20 в 21 29 30

Above problems appear only when using PHPageBuilder with docker.

My .env

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=33060
DB_DATABASE=db
DB_USERNAME=root
DB_PASSWORD=secret

My config/pagebuilder

    'storage' => [
        'use_database' => true,
        'database' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST').':'.env('DB_PORT',3306),
            'database'  => env('DB_DATABASE'),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => 'pagebuilder__',
        ],
        'uploads_folder' => storage_path('app/pagebuilder/uploads')
    ],
dsultanr commented 3 years ago

image

why do you have different ports in .env and config?

I think DB issue could not be the cause of "asset not found" error. What is the full path of app.css in browser?

AnastasiaKremenetskaya commented 3 years ago

I don't have different ports. env('DB_PORT',3306), means that if DB_PORT in env is empty then use default 3306 port. Full path is http://localhost/assets/websitemanager/app.css

dsultanr commented 3 years ago

but you have 33060 port in your .env

AnastasiaKremenetskaya commented 3 years ago

Yes, that's why default 3306 port won't be used. 3306 is used only when DB_PORT in .env is empty, my DB_PORT is not empty.

ehsantalkhouncheh commented 3 years ago

Hi @AnastasiaKremenetskaya , I have same issue did you find a solution for that?

AnastasiaKremenetskaya commented 3 years ago

Hi @ehsantalkhouncheh No, forced to discard usage

bluekable commented 1 year ago

Not sure if this applies to everyone using Docker but it definitely applies when installing Laravel for dev using Laravel Sail.

In vendor/hansschouten/phpagebuilder/src/Core/helpers.php in the phpb_current_full_url() method the full URL is generated using SERVER['SERVER_NAME'] which in the case of these docker containers in windows and WSL2 (not sure about in mac OS) is generally 0.0.0.0.

Then in the phpb_current_relative_url() method the relative URL is generated using both the returned value from the above mentioned phpb_current_full_url() and the value in phpb_config('general.base_url'); which in most cases is probably http://localhost.

Changing the ENV or config value for base_url doesn't solve the issue as redirects are sent to 0.0.0.0 then which breaks in the WSL2/Docker environment.