Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z set_include_path, Automatyczne ładowanie klas
nesquik_
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 28.02.2012

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


Witam.

Mam nadzieję, że piszę w dobrym dziale.
Mam taką strukturę plików:

  1. /app
  2. /controllers
  3. /libs
  4. /models
  5. /views
  6. /core
  7. /main
  8. registry.php
  9. /config
  10. /libs
  11. init.php
  12. index.php
  13. .htaccess
  14.  


Chodzi o to że w pliku init mam funkcje set_include_path oraz funkcje __autoload.
Plik init.php jest includowany do index.php
Jeśli w index.php chcę wywołać klasę registry (plik /core/registry.php) to dostaję błędy.

init.php
  1.  
  2. if(!isset($_SESSION)){session_start();}
  3.  
  4.  
  5.  
  6. set_include_path(get_include_path() . PATH_SEPARATOR . '/core/main');
  7. set_include_path(get_include_path() . PATH_SEPARATOR . '/core/libs');
  8. set_include_path(get_include_path() . PATH_SEPARATOR . '/core/config');
  9. set_include_path(get_include_path() . PATH_SEPARATOR . '/app/controllers');
  10. set_include_path(get_include_path() . PATH_SEPARATOR . '/app/views');
  11. set_include_path(get_include_path() . PATH_SEPARATOR . '/app/models');
  12. set_include_path(get_include_path() . PATH_SEPARATOR . '/app/libs');
  13.  
  14. function __autoload($name)
  15. {
  16. include_once($name.".php");
  17. }
  18.  
  19.  


index.php
  1. <?php
  2. include_once 'core/init.php';
  3. $router = registry::register('router');


błędy:

.;C:\xampp\php\PEAR
Warning: include_once(registry.php): failed to open stream: No such file or directory in C:\xampp\htdocs\wildcms\core\init.php on line 19

Warning: include_once(): Failed opening 'registry.php' for inclusion (include_path='.;C:\xampp\php\PEAR;/core/main;/core/libs;/core/config;/app/controllers;/app/views;/app/models;/app/libs') in C:\xampp\htdocs\wildcms\core\init.php on line 19

Fatal error: Class 'registry' not found in C:\xampp\htdocs\wildcms\index.php on line 3

Próbowałem już na innych serwerach(wamp, xamp)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Poczytaj o PSR-0 i PSR-4
Go to the top of the page
+Quote Post
nesquik_
post
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 28.02.2012

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


No poczytałem i nie bardzo rozumiem co mam złe?
Go to the top of the page
+Quote Post
redeemer
post
Post #4





Grupa: Zarejestrowani
Postów: 915
Pomógł: 210
Dołączył: 8.09.2009
Skąd: Tomaszów Lubelski/Wrocław

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


Kod
include_path='.;C:\xampp\php\PEAR;/core/main;/core/libs;/core/config;/app/controllers;/app/views;/app/models;/app/libs'
Co tu jest nie tak?

Ten post edytował redeemer 29.10.2014, 14:22:13


--------------------
Go to the top of the page
+Quote Post
nesquik_
post
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 28.02.2012

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


Nie mam pojęcia.
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




/app/views;
Czy Twoja aplikacja naprawdę leży w GŁÓWNYM KATALOGU twojego komputera? Smiem w to wątpic.... No i skoro używasz windows, to uzywaj zapis sciezek windowsowych.

Poza tym ustawianie petryliard include_path by ladowac "automatycznie" klasy to jakies nieporozumienie... Includuj klasy przy pomocy pelnych sciezek do nich i nie kombinuj bez sensu


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

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 Aktualny czas: 22.08.2025 - 07:42