when i used namespace,class loader prompt error

497 views
Skip to first unread message

netstu

unread,
Jan 15, 2013, 3:22:02 AM1/15/13
to pha...@googlegroups.com
Fatal error: Class 'Travker\SLibrary\Testlib' not found in /var/www/html/phalcon/app/controllers/IndexController.php on line 30

    public/index.php

    
$loader->registerDirs(
        array(
            $config->application->controllersDir,
            $config->application->modelsDir,
            $config->application->libraryDir . '/utils/',
            $config->application->libraryDir
        )
    );


Travker\SLibrary\Testlib  placed in $config->application->libraryDir . '/utils/',


Nikolaos Dimopoulos

unread,
Jan 15, 2013, 12:53:54 PM1/15/13
to pha...@googlegroups.com
Do this and have a look at the paths:

$paths = array(
            $config->application->controllersDir,
            $config->application->modelsDir,
            $config->application->libraryDir . '/utils/',
            $config->application->libraryDir
        );

var_dump($paths);

$loader->registerDirs($paths);

Maybe there is something in the array that it does not like.


The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.

Andres Gutierrez

unread,
Jan 15, 2013, 2:07:26 PM1/15/13
to pha...@googlegroups.com
The namespace separator (\) is replaced by the directory separator (/) so that class must be at:

$config->application->libraryDir . '/utils/Travker/SLibrary/Testlib.php'

2013/1/15 netstu <net...@gmail.com>



--
You received this message because you are subscribed to the Google Groups "Phalcon PHP Framework" group.
To post to this group, send email to pha...@googlegroups.com.
To unsubscribe from this group, send email to phalcon+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/phalcon/-/F4yh96JpJFMJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

netstu

unread,
Jan 15, 2013, 9:05:19 PM1/15/13
to pha...@googlegroups.com, andres.g...@phalconphp.com
@Nikolaos Dimopoulos
var_dump($path);
result:

array(4) { [0]=> string(55) "/var/www/html/phalcon/app/config/../../app/controllers/" [1]=> string(50) "/var/www/html/phalcon/app/config/../../app/models/" [2]=> string(58) "/var/www/html/phalcon/app/config/../../app/library//utils/" [3]=> string(51) "/var/www/html/phalcon/app/config/../../app/library/" }

@Andres Gutierrez

Testlib.php  in  /var/www/html/phalcon/app/config/../../app/library//utils/

not in /var/www/html/phalcon/app/config/../../app/library//utils/Travker/SLibrary

because i used registerDirs, not registernamespace()

used registerDirs method ,the absloutpath  have the namespace path?

在 2013年1月16日星期三UTC+8上午3时07分26秒,Andres Gutierrez写道:

netstu

unread,
Jan 15, 2013, 9:18:02 PM1/15/13
to pha...@googlegroups.com
ok

i add the namespace to filesystem path, now it works well.

i think used the registerDirs,not registerNamespace, it can found it.:)

在 2013年1月15日星期二UTC+8下午4时22分02秒,netstu写道:
Reply all
Reply to author
Forward
0 new messages