Saturday 29 December 2018

Symfony Apache configuration when app_dev is in a subdirectory

Hey guys I am running a Symfony 3 app on my local wondows machine. It's served with a XAMPP server. The app runs fine when i visite my local URL. The problems is that I can't seem to be able to run it in the dev envirement.

The Symfony app folder structure is diffrent then what I am used to. The app_dev.php is located in the intranet folder.

enter image description here

This is the intranet folder

enter image description here

My current apache config file looks like this:

<VirtualHost *:443>
    ServerName quebecenreseau.ca
    ServerAlias www.quebecenreseau.ca

    SSLEngine on
    SSLCertificateFile "crt/quebecenreseau.ca/server.crt"
    SSLCertificateKeyFile "crt/quebecenreseau.ca/server.key"

    DocumentRoot C:\xampp\htdocs\quebecenreseau
    <Directory C:\xampp\htdocs\quebecenreseau>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog C:\xampp\apache\logs\project_error.log
    CustomLog C:\xampp\apache\logs\project_access.log combined
</VirtualHost>

I am unsure how to configure the VirtualHost block in order to get the dev envirement working on both, the root directory as well as the intranet directory that serves as the admin of the website.

If I change the DocumentRoot line like so:

DocumentRoot C:\xampp\htdocs\quebecenreseau\intranet\app_dev.php

My app CSS files are not loaded and my intranet is served at the root level. How can I configure my local envirement to load app_dev.php? Also, my prod envirement is on a centos server so I really don't wana mess with the prod envirement.

In case you wander whats inside the index.php file at the root level here it is:

<?php

/**
 * Start session
 */

session_start();

/**
 * Load configuration and router
 */

require 'classes/Router.php';
require 'classes/Database.php';
require 'classes/Main.php';

/**
 * Load helpers
 */

require 'helpers/phpmailer/class.phpmailer.php';
require 'helpers/GUMP.php';
require 'helpers/MailChimp.php';


/**
 * Load models
 */

require 'models/Article.php';
require 'models/Formation.php';
require 'models/SAE.php';


/**
 * Load routes
 */

require 'router.php';


/**
 * Match requests
 */

$match = $router->match();

if( $match && is_callable( $match['target'] ) ) {
    // call function related to matched route
    call_user_func_array( $match['target'], $match['params'] );
} else {
    // no route was matched
    header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}



from Symfony Apache configuration when app_dev is in a subdirectory

No comments:

Post a Comment