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've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Empty _config.php file breaks CMS / Website

Go to End

5 Posts   7907 Views


Community Member, 38 Posts

23 April 2011 at 11:48pm

I have an empty _config.php file in a widget folder. This seem to break the CMS and front end of the website. If I look at the source of the CMS everything seems fine, but when I look at how the code gets parsed by browers, it seems like it ends the head earlier than it should.

I've included a screenshot wich shows some weird margin bug at the top of the screen and the code as seen by the browser.

Attached Files

Forum Moderator, 5523 Posts

24 April 2011 at 12:37pm

You should perhaps put at least a <?php line inside that file.

The empty space will likely be occurring since you have white space after a ?> tag. This is why our coding conventions recommend against using ?> tags.


Community Member, 38 Posts

24 April 2011 at 1:05pm

Thanks for the reply!

Tha's what I usually do, but then it injects the <?php in the first line of every page.

/admin/EditForm/ gives a JavaScript error when saving a page.

/admin/Editform now starts with:

$('Form_EditForm').loadActionsFromString('<input class=\"action  delete\" id=\"Form_EditForm_action_unpublish\"

When I look at the source of the cms the doctype line now looks like:

<?php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">

It seems to treat the php code as regular text.

When I close the tag again and put <?php ?> in the _config.php file, it doesn't show up in the source, but I get the same error as above because of the whitespace between the tags.


Community Member, 58 Posts

18 May 2011 at 9:11am

As a follow up: I ran into the same issue today.

If I put "<?php" into the _config.php file of a module, "<?php" is added at the very start of every page, right before the doctype. As soon as I add a newline to the configuration file, everything works as expected.

Not sure if this is a bug or the punishment for wrong usage, but it's definitely annoying and hard to debug...


Community Member, 271 Posts

19 May 2011 at 6:20am

I have the same thing..

I solve it with adding a // on the second line: