[Owncloud] How to autoload my class?

Bernhard Posselt nukeawhale at gmail.com
Wed Jun 5 16:04:36 UTC 2013


See
http://doc.owncloud.org/server/master/developer_manual/app/app/classloader.html

On 06/05/2013 05:04 PM, Arthur Schiwon wrote:
> On Wednesday, June 05, 2013 09:34:32 PM Naruto cartment idiot wrote:
>> Dear owncloud team:
>>      Sorry for my poor english!
>>      I saw the source code and most PHP Files do not use 'include' and
>> 'require' to load the class PHP File,i got confused,Maybe i am a new
>> PHPer...
>> If i create my Class file in /lib , how i can autoload it?
> The autoloader is defined here and so it works: 
> https://github.com/owncloud/core/blob/stable5/lib/base.php#L80
> (In master it is in libb/autoloader.php)
>
>>      I have read the document about how to develop an app.But i am
>> interested about the core function..
>  By the way,in
>> /settings/users.php,there is a code like:
>>      $accessibleusers = OC_User::getDisplayNames('', 30);
>>      I guess OC_User::getDisplayNames is used to get the users array,it work
>> ok in users page.
>  But i create a test.php,the code is like:
>>     <?php
>>         include'lib/test.php';
>>         $test=new Test();
>>         $user=$test->getUsers();
>>         print_r($user);
>>         //exit;
>>     ?>
> For a standalone script, you need to load ownCloud first: 
> require_once 'lib/base.php';
>
>>     and open the file in browser ,i got a empty array.
>>     What's Wrong?...
> You may want to browse through the existing code (and maybe apps) to see how 
> ownCloud works.
>
> Cheers
> Arthur
>
>>     Thank you!
> _______________________________________________
> Owncloud mailing list
> Owncloud at kde.org
> https://mail.kde.org/mailman/listinfo/owncloud




More information about the Owncloud mailing list