Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V   1 2 >  
Reply to this topicStart new topic
> [SF][Symfony2]localhost/.../web/ wyświetla zawartość katalogu zamiast stronę
twojastara
post 11.12.2014, 14:36:49
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


Uczę się Symfony2 z książki Gajdy i od razu, robiąc krok po kroku jak autor pisze, efekty mam nie takie jak autor pokazuje. Nawet pomińmy moje krok po kroku. Wklejając autora pliki przykładowych gotowych projektów efekty są złe.

(wrzucam gotowy projekt do wamp/www/)

Autor po wykonaniu (każdego) przykładu każe obejrzeć projekt pod poniższymi adresami pisząc, że efekt jest taki sam dla każdego adresu:

Dla 1 projektu (wersja autora)
localhost/hello-world/web/app_dev.php/hello-world.html - OK
localhost/hello-world/web/app.php/hello-world.html - OK
localhost/hello-world/web/hello-world.html - 404 Not Found

Dla 2 projektu (wersja autora)
localhost/mountains/web/ - Index of /mountain/web
localhost/mountains/web/valley.html - 404 Not Found
localhost/mountains/web/app.php/valley.html - OK
------
edit: dodaje efekty na symfony 2.6
Dla 2 projektu (wersja moja)
localhost/mountains/web/- wyświetla mi jakiś domyślny napis Homepage. Nie to co trzeba.
localhost/mountains/web/valley.html - 404 Not Found
localhost/mountains/web/app.php/valley.html - An Error Occurred- 404 Not Found(innaczej wyglądający niż ten 404 wyżej)
-------
Gdzie mam szukać przyczyny?


(powoli zacznę wrzucać fragmenty kodu, które autor każe wstawiać robiąc projekt, ale może juz na tym etapie ktoś wie w czym rzecz)

Ten post edytował twojastara 11.12.2014, 15:32:36
Go to the top of the page
+Quote Post
ohm
post 11.12.2014, 14:42:03
Post #2





Grupa: Zarejestrowani
Postów: 623
Pomógł: 144
Dołączył: 22.12.2010

Ostrzeżenie: (0%)
-----


Sprawdz czy masz plik .htaccess i mod_rewrite wlaczony.
Go to the top of the page
+Quote Post
phpion
post 11.12.2014, 14:42:42
Post #3





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Masz włączony mod_rewrite? W katalogu web obu aplikacji masz plik .htaccess?
Go to the top of the page
+Quote Post
twojastara
post 11.12.2014, 15:12:19
Post #4





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


W tym poście wklejam zawartość 4 plików .htaccess
Dwa autora robione na Symfony 2.0.10
Dwa moje robione w Symfony 2.6

-----------
edit (edytowałem tez pierwszy post)

/web/.htaccess gotowego projektu autora:
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. RewriteCond %{REQUEST_FILENAME} !-f
  4. RewriteRule ^(.*)$ app.php [QSA,L]
  5. </IfModule>


/web/.htaccess moje, nieruszane z Symfony 2.6
  1. # Use the front controller as index file. It serves as a fallback solution when
  2. # every other rewrite/redirect fails (e.g. in an aliased environment without
  3. # mod_rewrite). Additionally, this reduces the matching process for the
  4. # start page (path "/") because otherwise Apache will apply the rewriting rules
  5. # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
  6. DirectoryIndex app.php
  7.  
  8. <IfModule mod_rewrite.c>
  9. RewriteEngine On
  10.  
  11. # Determine the RewriteBase automatically and set it as environment variable.
  12. # If you are using Apache aliases to do mass virtual hosting or installed the
  13. # project in a subdirectory, the base path will be prepended to allow proper
  14. # resolution of the app.php file and to redirect to the correct URI. It will
  15. # work in environments without path prefix as well, providing a safe, one-size
  16. # fits all solution. But as you do not need it in this case, you can comment
  17. # the following 2 lines to eliminate the overhead.
  18. RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
  19. RewriteRule ^(.*) - [E=BASE:%1]
  20.  
  21. # Sets the HTTP_AUTHORIZATION header removed by apache
  22. RewriteCond %{HTTP:Authorization} .
  23. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  24.  
  25. # Redirect to URI without front controller to prevent duplicate content
  26. # (with and without `/app.php`). Only do this redirect on the initial
  27. # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
  28. # endless redirect loop (request -> rewrite to front controller ->
  29. # redirect -> request -> ...).
  30. # So in case you get a "too many redirects" error or you always get redirected
  31. # to the start page because your Apache does not expose the REDIRECT_STATUS
  32. # environment variable, you have 2 choices:
  33. # - disable this feature by commenting the following 2 lines or
  34. # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
  35. # following RewriteCond (best solution)
  36. RewriteCond %{ENV:REDIRECT_STATUS} ^$
  37. RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  38.  
  39. # If the requested filename exists, simply serve it.
  40. # We only want to let Apache serve files and not directories.
  41. RewriteCond %{REQUEST_FILENAME} -f
  42. RewriteRule .? - [L]
  43.  
  44. # Rewrite all other queries to the front controller.
  45. RewriteRule .? %{ENV:BASE}/app.php [L]
  46. </IfModule>
  47.  
  48. <IfModule !mod_rewrite.c>
  49. <IfModule mod_alias.c>
  50. # When mod_rewrite is not available, we instruct a temporary redirect of
  51. # the start page to the front controller explicitly so that the website
  52. # and the generated links can still be used.
  53. RedirectMatch 302 ^/$ /app.php/
  54. # RedirectTemp cannot be used instead
  55. </IfModule>
  56. </IfModule>


Projekt/source files/src/.htaccess w projekcie gotowym autora wygląda tak
  1. deny from all

Projekt/source files/src/.htaccess U mnie ten plik po komendzie generate:bundle wygląda tak:
  1. <IfModule mod_authz_core.c>
  2. Require all denied
  3. </IfModule>
  4. <IfModule !mod_authz_core.c>
  5. Order deny,allow
  6. Deny from all
  7. </IfModule>



a czy przypadkiem linia w /Apache/httpd.conf
  1. #LoadModule rewrite_module modules/mod_rewrite.so

nie powinna być bez komentarza?

Ten post edytował twojastara 11.12.2014, 17:30:12
Go to the top of the page
+Quote Post
Forti
post 11.12.2014, 17:42:45
Post #5





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


Powinna. Masz wyłączony mod_rewrite przez co htaccess nie działą tak jak powinien.


--------------------
Overwatch24 - najbardziej zaawansowany Polski portal Overwatch od fanów dla fanów.

Fachowo.co

Behance.net/fachowo
Go to the top of the page
+Quote Post
twojastara
post 12.12.2014, 09:34:16
Post #6





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


Zgadza się.
Projekty autora wyświetlają się teraz jak trzeba. Moje ciągle do dupy, ale już przynajmniej wiem, że przyczyna jest w plikach projektu.








------------------------------
edit:
Projekt autora (na Symfony 2.0.10) wyświetla się jak trzeba.

W moim projekcie robionym krok po kroku wg podrecznika wygenerowanym w Netbeans na Symfony 2.6. jest taki efekt:

localhost/mountains/web/- 500 Internal Server Error
localhost/mountains/web/valley.html - 404 Not Found
localhost/mountains/web/app.php/valley.html - 404 Not Found

404 z treścią z pliku C:\wamp\www\Mountains\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Resources\views\Exception\error.html.twig

Myślałem, że sobie spokojnie popatrzę na projekt autora porównam z moim projektem i znajdę różnice.

Ale praktycznie w każdym pliku projektu jest pełno różnic. Takich defaultowych jak mniemam, bo autor opisując przykłady krok po kroku o nich nie wspominał.

Gdzie powinienem szukać przyczyn?


Ten post edytował twojastara 12.12.2014, 09:17:58
Go to the top of the page
+Quote Post
Turson
post 12.12.2014, 09:38:13
Post #7





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Ksiązka opisuje wczesniejsza wersje niz 2.6 stad roznice. A url do AcmeBundle działa?
Go to the top of the page
+Quote Post
twojastara
post 12.12.2014, 11:13:48
Post #8





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


a jaki to będzie url?

---------
edit

jeśli
localhost/MySite/web/app_dev.php/demo/hello/Dennis- to jest ok
jeśli
localhost/MySite/web/app.php/demo/hello/Dennis - to przekierowuje na
localhost/MySite/web/demo/hello/Dennis - i jest 404 error

Ten post edytował twojastara 12.12.2014, 11:33:01
Go to the top of the page
+Quote Post
Turson
post 12.12.2014, 11:23:55
Post #9





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Chyba tylko app_dev ma routing do demo bundle
A nawet na pewno DemoBundle jest tylko dla dev

Ten post edytował Turson 12.12.2014, 11:25:13
Go to the top of the page
+Quote Post
twojastara
post 12.12.2014, 13:41:05
Post #10





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


no i co, jakieś wnioski w zwiazku z tym demo?
Go to the top of the page
+Quote Post
Turson
post 12.12.2014, 13:45:46
Post #11





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Masz routing do localhost/mountains/web/app.php/valley.html ? Czy tam umiesciles po prostu plik bo juz nie wiadomo
Go to the top of the page
+Quote Post
twojastara
post 12.12.2014, 16:32:23
Post #12





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


Po kolejnym przepisaniu przykładu wszystko jest jak trzeba. Jeszcze nie wiem gdzie zrobiłem babola. W międzyczasie wyczyściłem cache przeglądarek więc może to mi przeszkadzało.

---------------------------------
edit



a jak wytłumaczyć to, że w każdej przeglądarce na localhoscie mam wersję projektu z chwili jego tworzenia.

Późniejsze modyfikacje w ogóle nie są aktualizowane mimo restartu całego wampa, mimo twardego odświeżania przeglądarek, wyczyszczenia cache przegladarki, restartu komputera.

Co bym nie robił to wersja pliku
C:\wamp\www\MySite\src\My\LakeBundle\Resources\views\Default\index.html.twig
jest taka jak w chwili kiedy go pierwszy raz edytowałem.

jak zmienię nazwę tego pliku to strona nie pójdzie (error 500), ale jak zmienię np treść nagłówka w tym pliku to nie aktualizuje treści w przeglądarce.

Ten post edytował twojastara 12.12.2014, 16:41:27
Go to the top of the page
+Quote Post
ohm
post 12.12.2014, 17:48:45
Post #13





Grupa: Zarejestrowani
Postów: 623
Pomógł: 144
Dołączył: 22.12.2010

Ostrzeżenie: (0%)
-----


A testujesz na trybie produkcyjnym czy developerskim? Bo jeszcze czasem cache symphony (app/cache) trzeba wyczyścić smile.gif
Go to the top of the page
+Quote Post
twojastara
post 12.12.2014, 17:58:19
Post #14





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


app/cache?

nie widzę takiego folderu
Go to the top of the page
+Quote Post
Turson
post 12.12.2014, 20:17:53
Post #15





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


To ciekawe bo ja mam smile.gif
Go to the top of the page
+Quote Post
Forti
post 13.12.2014, 08:06:55
Post #16





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


W IDE często tego folderu nie ma. Sprawdź w eksploratorze czy tam finderze (zależnie od systemu).


--------------------
Overwatch24 - najbardziej zaawansowany Polski portal Overwatch od fanów dla fanów.

Fachowo.co

Behance.net/fachowo
Go to the top of the page
+Quote Post
twojastara
post 13.12.2014, 16:33:32
Post #17





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


no tak, w eksploratorze pokazuje się.

-----------
edit:

Cytat(ohm @ 12.12.2014, 17:48:45 ) *
A testujesz na trybie produkcyjnym czy developerskim?

Możesz coś więcej o tym napisać?
W jaki sposób przechodzi się między trybami?

Ten post edytował twojastara 13.12.2014, 16:35:36
Go to the top of the page
+Quote Post
Turson
post 13.12.2014, 16:39:19
Post #18





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


app.php - tryb produkcyjny
app_dev.php - developerski
Na dev domyślnie cache jest wyłączony i masz dostępny panel debugowania
Go to the top of the page
+Quote Post
twojastara
post 13.12.2014, 17:13:26
Post #19





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


rozumiem.
a jest jakiś powód bym nie zmieniał ustawień i nie wyłączał cache dla każdego trybu?
no bo trochę bez sensu co chwilę usuwać cache robiąc kolejne przykłady z książki.

Ten post edytował twojastara 13.12.2014, 17:13:57
Go to the top of the page
+Quote Post
Turson
post 13.12.2014, 17:31:14
Post #20





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Dev powinien mieć wyłaczone cache właśnie z tego powodu, żeby nie usuwać co zmianę
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 4.07.2025 - 14:50