Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Class not found, Problem z dostępem do klas
damianooo
post 18.09.2018, 10:53:47
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 2
Dołączył: 15.07.2011
Skąd: Katowice

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


Mój skrypt nie widzi klas i rzuca następującym błędem:
  1. Fatal error: Class 'Client' not found in C:\VertrigoServ\www\Stomp\stomp.php on line ...


mój skrypt stomp.php:

  1. // include a library
  2. require_once("src\Client.php");
  3. require_once("src\SimpleStomp.php");
  4. require_once("src\Protocol\Protocol.php");
  5. require_once("src\Protocol\Version.php");
  6. require_once("src\Transport\Frame.php");
  7. require_once("src\Transport\Message.php");
  8.  
  9. echo "TEST połączenia w protokole STOMP";
  10. echo "<br />";
  11.  
  12. // make a connection
  13. $stomp = new Client("tcp://localhost:8080");


Struktura katalogów jest taka:

Stomp/stomp.php
Stomp/src/Client.php

Klasa Client.php:

  1. namespace Stomp;
  2.  
  3. use Stomp\Exception\ConnectionException;
  4. use Stomp\Exception\MissingReceiptException;
  5. use Stomp\Exception\StompException;
  6. use Stomp\Exception\UnexpectedResponseException;
  7. use Stomp\Network\Connection;
  8. use Stomp\Protocol\Protocol;
  9. use Stomp\Protocol\Version;
  10. use Stomp\Transport\Frame;
  11.  
  12. /**
  13.  * Stomp Client
  14.  *
  15.  * This is the minimal implementation of a Stomp Client, it allows to send and receive Frames using the Stomp Protocol.
  16.  *
  17.  * @package Stomp
  18.  * @author Hiram Chirino <hiram@hiramchirino.com>
  19.  * @author Dejan Bosanac <dejan@nighttale.net>
  20.  * @author Michael Caplan <mcaplan@labnet.net>
  21.  * @author Jens Radtke <swefl.oss@fin-sn.de>
  22.  */
  23. class Client
  24. {
  25. /**
  26.   * Perform request synchronously
  27.   *
  28.   * @var boolean
  29.   */
  30. private $sync = true;


PS. Używam serwera www VertrigoServ z wersją PHP 5.6 bo taka jest potrzebna mi do przetestowania protokołu STOMP.


Dlaczego nie widzi mi tej klasy ?


Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
damianooo
post 18.09.2018, 20:38:01
Post #2





Grupa: Zarejestrowani
Postów: 496
Pomógł: 2
Dołączył: 15.07.2011
Skąd: Katowice

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


hmm , a więc da się to też tak zrobić ok ...

ale użyłem Twojego kodu i mam takie dwa błędy więc coś jeszcze nie tak:

  1. Warning: require(Stomp\Client.php): failed to open stream: No such file or directory in C:\VertrigoServ\www\Stomp\stomp.php on line 15

i
  1. Fatal error: require(): Failed opening required 'Stomp\Client.php' (include_path='.;C:\VertrigoServ\Smarty') in C:\VertrigoServ\www\Stomp\stomp.php on line 15



doczytałem trochę o autładowaniu klas:
https://pl.wikibooks.org/wiki/PHP/Automatyc..._%C5%82adowanie

i widzę że można kod skrócić nawet do tego:

  1. function myClassLoader($className){
  2. echo 'Ładuję klasę '.$className.'<br/>';
  3. require('./'.$className.'.php');
  4. // Zwróć "true", informując, że klasa została znaleziona.
  5. return true;
  6.  
  7. } // end myClassLoader();
  8.  
  9. spl_autoload_register('myClassLoader');
  10.  
  11. $stomp = new \Stomp\Client("tcp://localhost:8080");


tylko że co ciekawe ciągle mam te dwa powyższe błędy sad.gif ... masakra



Ten post edytował damianooo 18.09.2018, 20:57:15
Go to the top of the page
+Quote Post

Posty w temacie


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: 10.06.2024 - 15:52