Fwd: ZF2: Remove .htaccess in getting started tutorial

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: ZF2: Remove .htaccess in getting started tutorial

ThaDafinser

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: 31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

aboozar
Hello to all
I think
this is one of the best methods but this idea for beginners is somewhat problematic.
On the other hand, the possibility of using this Application without defining the vhost should also be possible.

Regards
Aboozar Ghafari




On Wed, Aug 1, 2012 at 1:06 AM, Martin Keckeis <[hidden email]> wrote:

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: 31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

Tomáš Fejfar
Also 90% of PHP hosting solutions allow .htacces but NOT vhost config. 

On Tue, Jul 31, 2012 at 11:06 PM, Aboozar Ghafari <[hidden email]> wrote:
Hello to all
I think
this is one of the best methods but this idea for beginners is somewhat problematic.
On the other hand, the possibility of using this Application without defining the vhost should also be possible.

Regards
Aboozar Ghafari




On Wed, Aug 1, 2012 at 1:06 AM, Martin Keckeis <[hidden email]> wrote:

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: <a href="tel:31.07.2012%2011" value="+13107201211" target="_blank">31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

Matus Zeman
In reply to this post by aboozar
Hi Martin,
everything you said is correct -- but that's more for production deployment than for development.
we tend to develop using htaccess and once we're on production server we move everything to apache vhost configuration.

Matus

On Tue, Jul 31, 2012 at 11:06 PM, Aboozar Ghafari <[hidden email]> wrote:
Hello to all
I think
this is one of the best methods but this idea for beginners is somewhat problematic.
On the other hand, the possibility of using this Application without defining the vhost should also be possible.

Regards
Aboozar Ghafari




On Wed, Aug 1, 2012 at 1:06 AM, Martin Keckeis <[hidden email]> wrote:

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: <a href="tel:31.07.2012%2011" value="+13107201211" target="_blank">31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

Frank Brückner
In reply to this post by Tomáš Fejfar
Am 01.08.2012, 00:30 Uhr, schrieb Tomáš Fejfar <[hidden email]>:

> Also 90% of PHP hosting solutions allow .htacces but NOT vhost config.

+1
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

ThaDafinser
In reply to this post by Matus Zeman
Hi,

i don't make a difference between production and development (except for some needed things like error output, logging, ...).
It's general no good idea to have different "enviroments" (because it can lead to further errors), so i use this method in both cases.

@Aboozar you are right, there should be both ways available.

Case 1) Modification of vhosts is allowed
You can use the example below (without .htaccess)

Case 2) Only .htaccess modification, no vhosts
SenEnv APPLICATION_ENV "development" could be moved to .htaccess

ServerName / DocumentRoot cannot be defined in .htaccess so how deal with that? 
Can this be done in every hosting enviroment over the GUI?

Best Regards
Martin Keckeis


2012/8/1 Matus Zeman <[hidden email]>
Hi Martin,
everything you said is correct -- but that's more for production deployment than for development.
we tend to develop using htaccess and once we're on production server we move everything to apache vhost configuration.

Matus

On Tue, Jul 31, 2012 at 11:06 PM, Aboozar Ghafari <[hidden email]> wrote:
Hello to all
I think
this is one of the best methods but this idea for beginners is somewhat problematic.
On the other hand, the possibility of using this Application without defining the vhost should also be possible.

Regards
Aboozar Ghafari




On Wed, Aug 1, 2012 at 1:06 AM, Martin Keckeis <[hidden email]> wrote:

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: <a href="tel:31.07.2012%2011" value="+13107201211" target="_blank">31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin



Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

ThaDafinser
Maybe another point of view.

The quick start guide is really good written by Rob,
but a "quick start guide" is often used for:
- start of a complete project (without changing those parts, which are needed)
- benchmarking the framework
- a short look and feel over a project
- ...

So it should be as good as possible, because this is how the framework is seen from people which are not involved directly or want to compare it with another.

The .htaccess / vhosts thing is only a small part i know.

One goal for ZF2 was also performance, so if a benchmark is done with the quick start guide everybody would like to see good numbers ;-)

Best regards
Martin Keckeis

2012/8/1 Gary Hockin <[hidden email]>

I don't really feel that this is a valid zf2 discussion. The tutorial is for people getting started with the framework, and as such Rob's .htaccess method is fine; it allows a new user to start using the framework quickly.

G

On Aug 1, 2012 7:17 AM, "Martin Keckeis" <[hidden email]> wrote:
Hi,

i don't make a difference between production and development (except for some needed things like error output, logging, ...).
It's general no good idea to have different "enviroments" (because it can lead to further errors), so i use this method in both cases.

@Aboozar you are right, there should be both ways available.

Case 1) Modification of vhosts is allowed
You can use the example below (without .htaccess)

Case 2) Only .htaccess modification, no vhosts
SenEnv APPLICATION_ENV "development" could be moved to .htaccess

ServerName / DocumentRoot cannot be defined in .htaccess so how deal with that? 
Can this be done in every hosting enviroment over the GUI?

Best Regards
Martin Keckeis


2012/8/1 Matus Zeman <[hidden email]>
Hi Martin,
everything you said is correct -- but that's more for production deployment than for development.
we tend to develop using htaccess and once we're on production server we move everything to apache vhost configuration.

Matus

On Tue, Jul 31, 2012 at 11:06 PM, Aboozar Ghafari <[hidden email]> wrote:
Hello to all
I think
this is one of the best methods but this idea for beginners is somewhat problematic.
On the other hand, the possibility of using this Application without defining the vhost should also be possible.

Regards
Aboozar Ghafari




On Wed, Aug 1, 2012 at 1:06 AM, Martin Keckeis <[hidden email]> wrote:

2nd try...(wrong email)

---------- Weitergeleitete Nachricht ----------
Von: "Martin Keckeis" <[hidden email]>
Datum: <a href="tel:31.07.2012%2011" value="+13107201211" target="_blank">31.07.2012 11:07
Betreff: ZF2: Remove .htaccess in getting started tutorial
An: "Rob Allen" <[hidden email]>
Cc: <[hidden email]>

Hello Rob/Contributors,

in the beginning of the "Get started with ZF2" tutorial, there is the Apache configuration explained.
Which includes a .htaccess file

Wouldn't it be a lot nicer, to skip this .htaccess file and define all in the virtual host?
- You can deny AllowOverride, so Apache don't search for .htaccess (Performance)
- Apache must not read a .htaccess file for each request (Performance)
- you only have to maintain one file

My current implementation (changed for the tutorial):

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf-2tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride none

        Order allow,deny
        Allow from all

        # currently in .htaccess
        RewriteEngine On
        # Special "public" files are not rewritten (maybe need to be modified)
        # may be in most cases only CSS, JS and images!
    RewriteRule !.(js|css|ico|gif|jpg|png|pdf|xls|xlsx|html)$ index.php
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </Directory>
</VirtualHost> 


Best regards
Martin




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: ZF2: Remove .htaccess in getting started tutorial

Artur Bodera
On Wed, Aug 1, 2012 at 1:47 PM, Martin Keckeis <[hidden email]> wrote:
The .htaccess / vhosts thing is only a small part i know.
One goal for ZF2 was also performance, so if a benchmark is done with the quick start guide everybody would like to see good numbers ;-)


First of all, thank you for your tip and your time. 
You're right with your rationale, though there are more important facts to consider.
 
You're probably relating to this:

- Yes, htaccess is a performance hit. 
- It is enabled on most linux distrubution by default and apache will always attempt to find the file (for each request).
- It is enabled on most shared hosting and VPS hosting around the world.
- It is the most common way to introduce apache config changes (including rewrites) in PHP/LAMP world. If you skim through tutorials for Drupal, Symfony2, Wordpress, Cake, or any other library/framework that depends on rewrites, that's the default, standard way of doing things.
- Most PHP Frameworks' performance benchmarks are run _with_ .htaccess and rewrite rules inside them.
- 95% of the time (first-byte) consumed in a ZF2 application is the PHP code itself. I'd bet .htaccess overhead is in the range of 0.01 - 0.10 ms. On the other hand, PHP execution takes anything from 50ms up to a few seconds (on a moderately loaded, well-configured server with optimized app).
- Your suggestion is valid in performance terms. Moving to vhost configuration _does_ increase performance by some microseconds.
- Your suggestion is not valid in terms of common standards.
- Your suggestion increases learning curve and will be hard to understand for newcomers (or experienced PHP programmers, but not fluent in server configuration/administration).
- VHost configuration must not be a default way of installing (starting with) Zend Framework 2, because of the above.
- On the other hand, even if we did _not_ include this suggestion in the tutorial, experienced server administrators are already familiar with this fact and will move .htaccess rules into vhost config regardless.
- Previous point also applies to people who are experienced in scaling web applications, those who want to shave off every milisecond in multi-thousand TPS environment.


My suggestion: leave it be.


-- 
      __
     /.)\   +48 695 600 936
     \(./   [hidden email]


 
Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

akrabat
In reply to this post by ThaDafinser
Hi all,

I'm back from holiday, though it will take me a few days to catch up on email!

The main reason that I've always used .htaccess is to lower the barrier to entry for newcomers to the framework and hence allow more people to actually get a working application.

Regards,

Rob...

On 1 Aug 2012, at 12:47, Martin Keckeis <[hidden email]> wrote:

> Maybe another point of view.
>
> The quick start guide is really good written by Rob,
> but a "quick start guide" is often used for:
> - start of a complete project (without changing those parts, which are needed)
> - benchmarking the framework
> - a short look and feel over a project
> - ...
>
> So it should be as good as possible, because this is how the framework is seen from people which are not involved directly or want to compare it with another.
>
> The .htaccess / vhosts thing is only a small part i know.
>
> One goal for ZF2 was also performance, so if a benchmark is done with the quick start guide everybody would like to see good numbers ;-)
>
> Best regards
> Martin Keckeis
>

Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

Shahar Evron-2

On Thu, Aug 16, 2012 at 3:01 PM, Rob Allen <[hidden email]> wrote:
Hi all,

I'm back from holiday, though it will take me a few days to catch up on email!

The main reason that I've always used .htaccess is to lower the barrier to entry for newcomers to the framework and hence allow more people to actually get a working application.


I'm not sure if we are assuming PHP 5.4 or not, but it could be a nice idea to suggest using the built-in Web server for development. It's super easy, as opposed to setting up an Apache or other based environment which as I have seen leads to quite a lot of frustrations for many newcomers.

I have blogged about using the built-in WS with ZF here: http://arr.gr/blog/2012/08/serving-zf-apps-with-the-php-54-built-in-web-server/

While using .htaccess files works nicely in most cases, when it doesn't (due to some specific Apache configuration or special project setup, e.g. an Alias instead of a vhost) it's a major frustration. The built-in WS will work on all configurations and of course no need to set up virtual hosts, symlinks or aliases when working with multiple projects.

We can still suggest the .htaccess approach for PHP 5.3 users (while encouraging them to upgrade - two birds on one stone!) and but a big note about not using this setup for production, but for dev purposes only, with a reference to the docs on how to set things up with production-grade Web servers.

Shahar.
 
Regards,

Rob...

On 1 Aug 2012, at 12:47, Martin Keckeis <[hidden email]> wrote:

> Maybe another point of view.
>
> The quick start guide is really good written by Rob,
> but a "quick start guide" is often used for:
> - start of a complete project (without changing those parts, which are needed)
> - benchmarking the framework
> - a short look and feel over a project
> - ...
>
> So it should be as good as possible, because this is how the framework is seen from people which are not involved directly or want to compare it with another.
>
> The .htaccess / vhosts thing is only a small part i know.
>
> One goal for ZF2 was also performance, so if a benchmark is done with the quick start guide everybody would like to see good numbers ;-)
>
> Best regards
> Martin Keckeis
>


Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

akrabat

On 18 Aug 2012, at 10:43, Shahar Evron <[hidden email]> wrote:

> I'm not sure if we are assuming PHP 5.4 or not, but it could be a nice idea to suggest using the built-in Web server for development. It's super easy, as opposed to setting up an Apache or other based environment which as I have seen leads to quite a lot of frustrations for many newcomers.
>
> I have blogged about using the built-in WS with ZF here: http://arr.gr/blog/2012/08/serving-zf-apps-with-the-php-54-built-in-web-server/ 
>
> While using .htaccess files works nicely in most cases, when it doesn't (due to some specific Apache configuration or special project setup, e.g. an Alias instead of a vhost) it's a major frustration. The built-in WS will work on all configurations and of course no need to set up virtual hosts, symlinks or aliases when working with multiple projects.
>
> We can still suggest the .htaccess approach for PHP 5.3 users (while encouraging them to upgrade - two birds on one stone!) and but a big note about not using this setup for production, but for dev purposes only, with a reference to the docs on how to set things up with production-grade Web servers.
>
> Shahar.

Interesting. I don't have PHP 5.4 on any production server, so do not use 5.4 on a dev box either. I'm sure someone who does use it could provide the relevant changes to Skeleton to ensure that the equivalent of mod_rewrite works with the built in 5.4 web server.

I'm not sure I would use the built-in web server once we move to 5.4 either, but then I think we're maybe unusual in having so many websites in action simultaneously.

Regards,

Rob...


Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

Andreas Möller
> Interesting. I don't have PHP 5.4 on any production server, so do not use 5.4 on a dev box either. I'm sure someone who does use it could provide the relevant changes to Skeleton to ensure that the equivalent of mod_rewrite works with the built in 5.4 web server.
>
> I'm not sure I would use the built-in web server once we move to 5.4 either, but then I think we're maybe unusual in having so many websites in action simultaneously.

As far as I remember from following the discussions on the mailing
list, PHP 5.3 is required as a minimum. Therefore I suggest that
documentation is laid out for a typical development stack with PHP
5.3, too.


Best regards,

Andreas
Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

weierophinney
Administrator
In reply to this post by Shahar Evron-2
-- Shahar Evron <[hidden email]> wrote
(on Saturday, 18 August 2012, 12:43 PM +0300):

> On Thu, Aug 16, 2012 at 3:01 PM, Rob Allen <[hidden email]> wrote:
>
>     Hi all,
>
>     I'm back from holiday, though it will take me a few days to catch up on
>     email!
>
>     The main reason that I've always used .htaccess is to lower the barrier to
>     entry for newcomers to the framework and hence allow more people to
>     actually get a working application.
>
> I'm not sure if we are assuming PHP 5.4 or not, but it could be a nice idea to
> suggest using the built-in Web server for development. It's super easy, as
> opposed to setting up an Apache or other based environment which as I have seen
> leads to quite a lot of frustrations for many newcomers.
>
> I have blogged about using the built-in WS with ZF here: http://arr.gr/blog/
> 2012/08/serving-zf-apps-with-the-php-54-built-in-web-server/

Nice post, by the way!

Two points of correction, however: First, I've found I've had no problem
serving static files via the built-in server; they "just work". Second,
the last argument to the server doesn't have to be a file -- it can be a
directory. If it's a directory, it will look for either index.php or
index.html in order to serve from it. As such, I usually start things up
using:

    php -S localhost:8080 public

and all is good. :)

I do think it's worth adding a section on this to the quick start guide.
While I don't think 5.4 has anywhere near critical adoption at this
point, for those using it, it's a great way to experiment with the
framework.

> While using .htaccess files works nicely in most cases, when it doesn't (due to
> some specific Apache configuration or special project setup, e.g. an Alias
> instead of a vhost) it's a major frustration. The built-in WS will work on all
> configurations and of course no need to set up virtual hosts, symlinks or
> aliases when working with multiple projects.
>
> We can still suggest the .htaccess approach for PHP 5.3 users (while
> encouraging them to upgrade - two birds on one stone!) and but a big note about
> not using this setup for production, but for dev purposes only, with a
> reference to the docs on how to set things up with production-grade Web
> servers.
>
> Shahar.
>  
>
>     Regards,
>
>     Rob...
>
>     On 1 Aug 2012, at 12:47, Martin Keckeis <[hidden email]> wrote:
>
>     > Maybe another point of view.
>     >
>     > The quick start guide is really good written by Rob,
>     > but a "quick start guide" is often used for:
>     > - start of a complete project (without changing those parts, which are
>     needed)
>     > - benchmarking the framework
>     > - a short look and feel over a project
>     > - ...
>     >
>     > So it should be as good as possible, because this is how the framework is
>     seen from people which are not involved directly or want to compare it with
>     another.
>     >
>     > The .htaccess / vhosts thing is only a small part i know.
>     >
>     > One goal for ZF2 was also performance, so if a benchmark is done with the
>     quick start guide everybody would like to see good numbers ;-)
>     >
>     > Best regards
>     > Martin Keckeis
>     >
>
>
>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|

Re: ZF2: Remove .htaccess in getting started tutorial

Shahar Evron-2

On Mon, Aug 20, 2012 at 5:36 PM, Matthew Weier O'Phinney <[hidden email]> wrote:
-- Shahar Evron <[hidden email]> wrote
(on Saturday, 18 August 2012, 12:43 PM +0300):
> On Thu, Aug 16, 2012 at 3:01 PM, Rob Allen <[hidden email]> wrote:
>
>     Hi all,
>
>     I'm back from holiday, though it will take me a few days to catch up on
>     email!
>
>     The main reason that I've always used .htaccess is to lower the barrier to
>     entry for newcomers to the framework and hence allow more people to
>     actually get a working application.
>
> I'm not sure if we are assuming PHP 5.4 or not, but it could be a nice idea to
> suggest using the built-in Web server for development. It's super easy, as
> opposed to setting up an Apache or other based environment which as I have seen
> leads to quite a lot of frustrations for many newcomers.
>
> I have blogged about using the built-in WS with ZF here: http://arr.gr/blog/
> 2012/08/serving-zf-apps-with-the-php-54-built-in-web-server/

Nice post, by the way!

Two points of correction, however: First, I've found I've had no problem
serving static files via the built-in server; they "just work". Second,
the last argument to the server doesn't have to be a file -- it can be a
directory. If it's a directory, it will look for either index.php or
index.html in order to serve from it. As such, I usually start things up
using:

    php -S localhost:8080 public

and all is good. :)

Hmmm.. last time I tried that (or maybe I left out the dir name?) it did not work - static files were missing. If it indeed "just works" that's even better!
 

I do think it's worth adding a section on this to the quick start guide.
While I don't think 5.4 has anywhere near critical adoption at this
point, for those using it, it's a great way to experiment with the
framework.

I agree, plus it's so easy to do that it's almost a no-brainer to document it, even as a side note / foot note.

That said, today I encountered a E_WARNING bug (it seems pretty much harmless besides the fact that an E_WARNING is triggered) related to the built-in web server - see http://framework.zend.com/issues/browse/ZF2-480. We should probably run some more tests before adding that option to the official docs.

Shahar.
 

> While using .htaccess files works nicely in most cases, when it doesn't (due to
> some specific Apache configuration or special project setup, e.g. an Alias
> instead of a vhost) it's a major frustration. The built-in WS will work on all
> configurations and of course no need to set up virtual hosts, symlinks or
> aliases when working with multiple projects.
>
> We can still suggest the .htaccess approach for PHP 5.3 users (while
> encouraging them to upgrade - two birds on one stone!) and but a big note about
> not using this setup for production, but for dev purposes only, with a
> reference to the docs on how to set things up with production-grade Web
> servers.
>
> Shahar.
>
>
>     Regards,
>
>     Rob...
>
>     On 1 Aug 2012, at 12:47, Martin Keckeis <[hidden email]> wrote:
>
>     > Maybe another point of view.
>     >
>     > The quick start guide is really good written by Rob,
>     > but a "quick start guide" is often used for:
>     > - start of a complete project (without changing those parts, which are
>     needed)
>     > - benchmarking the framework
>     > - a short look and feel over a project
>     > - ...
>     >
>     > So it should be as good as possible, because this is how the framework is
>     seen from people which are not involved directly or want to compare it with
>     another.
>     >
>     > The .htaccess / vhosts thing is only a small part i know.
>     >
>     > One goal for ZF2 was also performance, so if a benchmark is done with the
>     quick start guide everybody would like to see good numbers ;-)
>     >
>     > Best regards
>     > Martin Keckeis
>     >
>
>
>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc