Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing <?php tags? #46

Open
RussellAult opened this issue May 17, 2021 · 6 comments
Open

Missing <?php tags? #46

RussellAult opened this issue May 17, 2021 · 6 comments
Labels
Documentation Enhancement Question Further information is requested

Comments

@RussellAult
Copy link

I'm not experience enough with PHP to know the source of the issue, but I've been working my way through the tutorial and when I got to the "try it out!" step at the end of "Database and Models" the contents of my PHP files were being displayed verbatim. I had to go back through and add <?php to the beginning of the all the .php files I had created, and now everything works. For what it's worth I'm using Apache as the server.

Did I miss something in the tutorial that would cover this? Do not all web servers require a PHP tag at the beginning of the file anymore?

@RussellAult RussellAult added the Bug Something isn't working label May 17, 2021
@Ocramius
Copy link
Member

Ocramius commented May 17, 2021 via email

@RussellAult
Copy link
Author

@Ocramius Perhaps I'm not the target audience, but the last time I did anything that might be called "web development" was before application frameworks were a thing, so when an instruction says "Let's create that file now, with the following contents:" I follow those instructions verbatim. So, at a minimum, every time the entire contents of a particular file except for the <?php tag is given, it's particularly unclear to me that the tag has been omitted (especially because the convention isn't mentioned anywhere).

Is there an advantage to omitting the <?php tag?

@RussellAult
Copy link
Author

Also, part of my confusion stems from the fact that sometimes (like with .phtml files) the <?php tag is included explicitly, which reinforces the impression that it's not necessary in the other files.

@Ocramius
Copy link
Member

Ocramius commented May 17, 2021

Is there an advantage to omitting the <?php tag?

Generally yes, as examples are very often isolated to code fragments, rather than entire files. We also don't include things like the current namespace, or all the imports, since docs are for reference, not copy-pasteable code in most cases.

For .phtml files, the PHP tag is included explicitly because by default, you are operating within text output context, rather than in PHP context.

Other libraries/tools in the PHP ecosystem also omit the opening <?php declaration in docs, but perhaps confusion for newcomers should be a signal that this could change for laminas/tutorials perhaps? /cc @froschdesign

@Ocramius Ocramius added Documentation Enhancement Question Further information is requested and removed Bug Something isn't working labels May 17, 2021
@RussellAult
Copy link
Author

I think that makes a lot of sense for the fragments.

For me, the confusion stems from the fact that, unlike with most documentation, several of the examples in the tutorial imply that they are the entire contents of a given file (i.e. I think it's confusing when every line of a file is shown except for the first one).

@froschdesign
Copy link
Member

@RussellAult

Perhaps I'm not the target audience…

The target group are experienced PHP programmers because it is not the task of the documentation to explain the basics. Unfortunately, this would go beyond any capacities.

But the current plan already includes this topic and we will provide the full code and add links in the documentation. But before that, we will rework the tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Enhancement Question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants