<p dir="auto">I was going to write a PR for FOSAdvancedEncoder for the new encoders (bcrypt, pbkdf2) and I noticed it's pretty much a duplicate of the core EncoderFactory. it seems a waste to maintain a separate bundle for this simple functionality.<br>
My suggestion is to add this small feature to the core EncoderFactory.</p>
<ul dir="auto">
<li>Does anybody else think the same?</li>
<li>I need an idea how to build the new config so it won't have BC issues</li>
</ul>
<p dir="auto">Use case: different encoder (or bcrypt cost) for user/admin</p>
<p dir="auto">Take for instance you have a mod_rewrite in apache to redirect all requests through to index.php (common practice for "pretty" urls)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
&lt;/IfModule&gt;"><pre class="notranslate"><code class="notranslate">&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
&lt;/IfModule&gt;
</code></pre></div>
<p dir="auto">If you request for a url like: <code class="notranslate">http://my-site.com/fruit/strawberry/index.php/blah</code> the base url comes back as <code class="notranslate">blah</code>. I would expect the base to be <code class="notranslate">/</code> and segments to be <code class="notranslate">fruit/strawberry/index.php/blah</code> due to the mod_rewrite.</p>
<p dir="auto">The issue is caused by the <code class="notranslate">basename</code> in the very top lines in <code class="notranslate">prepareBaseUrl</code> as below:</p>
<p dir="auto"><strong>src/Symfony/Component/HttpFoundation/Request.php</strong></p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    /**
     * Prepares the base URL.
     *
     * @return string
     */
    protected function prepareBaseUrl()
    {
        $filename = basename($this-&gt;server-&gt;get('SCRIPT_FILENAME'));
        if (basename($this-&gt;server-&gt;get('SCRIPT_NAME')) === $filename) {
            $baseUrl = $this-&gt;server-&gt;get('SCRIPT_NAME');"><pre class="notranslate">    <span class="pl-c">/**</span>
<span class="pl-c">     * Prepares the base URL.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * @return string</span>
<span class="pl-c">     */</span>
    <span class="pl-k">protected</span> <span class="pl-k">function</span> prepareBaseUrl()
    {
        <span class="pl-s1"><span class="pl-c1">$</span>filename</span> = basename(<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">server</span>-&gt;<span class="pl-en">get</span>(<span class="pl-s">'SCRIPT_FILENAME'</span>));
        <span class="pl-k">if</span> (basename(<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">server</span>-&gt;<span class="pl-en">get</span>(<span class="pl-s">'SCRIPT_NAME'</span>)) === <span class="pl-s1"><span class="pl-c1">$</span>filename</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span>baseUrl</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">server</span>-&gt;<span class="pl-en">get</span>(<span class="pl-s">'SCRIPT_NAME'</span>);</pre></div>
<p dir="auto">My request looks as below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="REQUEST_URI = /fruit/test/index.php/blah
SCRIPT_FILENAME = E:/Sites/cc-new/public_html/index.php
SCRIPT_NAME = /index.php"><pre class="notranslate"><code class="notranslate">REQUEST_URI = /fruit/test/index.php/blah
SCRIPT_FILENAME = E:/Sites/cc-new/public_html/index.php
SCRIPT_NAME = /index.php
</code></pre></div>
<p dir="auto">Essentially what it's doing is getting the <code class="notranslate">SCRIPT_FILENAME</code>, doing a <code class="notranslate">basename</code> which turns it into simply <code class="notranslate">index.php</code>.</p>
<p dir="auto">Then <code class="notranslate">SCRIPT_NAME</code> goes through <code class="notranslate">basename</code> too so it end's up doing <code class="notranslate">index.php == index.php</code> which is true then set's the base as the <code class="notranslate">SCRIPT_NAME</code> i.e. simply index.php</p>
<p dir="auto">This is incorrect, it should set the base to <code class="notranslate">/</code> only. Something weird is going on with the use of <code class="notranslate">basename</code>....?</p>