odan / slim4-skeleton

A Slim 4 Skeleton
https://odan.github.io/slim4-skeleton/
MIT License
446 stars 80 forks source link

Twig assets #7

Closed 262925 closed 4 years ago

262925 commented 4 years ago

I did followed your tutorial twig-webpack-extension-setup with this skeleton which getting error 404. Do you have any idea what cause the problem?

image

odan commented 4 years ago

I'm not sure what you have tried, but try this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <base href="{{ base_path() }}/"/>
262925 commented 4 years ago

Just creating own simple cms to learn. Thank you so much for your skeleton which great start-up for new Slim learners. I already did mentioned things. Console return 404 errors. image

image

image

odan commented 4 years ago

Looks good, so far. Try to find the "correct" url for the main.js/main.css files manually.

262925 commented 4 years ago

Actually same working on Hosting server but in the localhost. Any idea for it.?

odan commented 4 years ago

Sounds like an typical basePath issue if you run Slim in an sub-directory (applies for most development environments). Please give me more details (error message & code, screenshot, directory, etc...).

262925 commented 4 years ago

Running directory is c/wamp/www/dts(simple cms). I used your skeleton nothing else. I added some screenshot here. please let me know if you need anything else. Thank you.

Container: image image

Middleware image

Error: image

Composer.json image

odan commented 4 years ago

Your app is running in a sub-directory (under c/wamp/www/dts). So the BasePathMiddleware should set Slims basePath to /dts automatically for you.

What is the output of the Twig helper function base_path() ? in your layout/layout.wig file here:

 <base href="{{ base_path() }}/"/>

On your localhost the output should be: <base href="dts/"/> On your prod server the output should be: <base href="/"/>

dunkoh commented 4 years ago

Is your host root pointed to the public directory inside dts?

262925 commented 4 years ago

What is the output of the Twig helper function base_path() ?

@odan Return <base href="/"/> - where do i change that?

262925 commented 4 years ago

Is your host root pointed to the public directory inside dts?

@dunkoh i think yes. C:\wamp\www\dts>php -S localhost:8080 -t public public/index.php

odan commented 4 years ago

Good hint from @dunkoh. I thought you were using Apache. If you use the PHP internal web server, you can try this command:

cd c:\wamp\www\dts php -S localhost:8080 -t public

Then navigate to: http://localhost:8080/

The base href should then look like this: <base href="/"/>

262925 commented 4 years ago

@odan Which is works cool!. Thank you.