views:

54

answers:

2

Hi there!

Sorry the basic doubt but is there any recommended way to open a file using symfony? I'm trying to open a MarkDown source file.

Thanks for the help, Best regards!

+2  A: 

I don't think there is a special symfony way.
Just use the normal PHP filesystem functions for that, e.g. file_get_contents

Felix Kling
Hi!Before of anything, thanks for the help. I had placed the markdown source file in the following location of the symfony project: doc/markdown/source/ but using the php function file_exists it returns always FALSE. The complete path for the file that I desire to open is: /ccam/doc/markdown/source/QuickStart.mdtxt.Any suggestion for the motive that I can't open the file?Best regards!
Rui Gonçalves
@Rui Gonçalves: Do you use the relative or the absolute path?
Felix Kling
Hi there!I was using the absolute path but I now realized that must be used a relative path. Can you tell me why the reason?Best regards!
Rui Gonçalves
A: 

The sfMarkdownPlugin README file details the Markdown processing for file contents. In the directions it uses the symfony 'data' directory to store the file, and uses the sfConfig class to access the file contents.

$file = sfConfig::get('sf_data_dir').'/content/about.txt';
if (!is_readable($file))
...

You asked for a symfony way to read a file, there it is.

See further; http://www.symfony-project.org/plugins/sfMarkdownPlugin/0_1_1?tab=plugin_readme

Ghostpsalm