Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Beginner: Help on how to use your own classes?

Go to End

4 Posts   1683 Views


Community Member, 36 Posts

28 May 2010 at 10:23pm


I've been hunting a round for something to get my foot in the door.

Can someone help me work out how to use my own classes or other classes (e.g something from in my silverstripe modules?

Even a quick outline of whats required is fine, I don't need exact details :)



Community Member, 57 Posts

29 May 2010 at 11:44am


You can use them just as you would any other class and then simply 'require' them and use as normal, ie:

require './external_class.php';

class NewPage_Controller extends Page_Controller {

function init() {
 $external = new ExternalClass();
 return $this;


Forum Moderator, 5523 Posts

29 May 2010 at 2:39pm

Or if you put the code in your mysite folder (well any module folder) SS will automatically include the PHP class for you as long as its somewhere in the app.

Eg if you have someclass.php in mysite/code/ you can straight away reference that class without any require lines.


Community Member, 36 Posts

29 May 2010 at 10:11pm

Awesome, thanks for being so helpful. I'll give it a shot!