了解 Symfony2 中的架构和文件夹结构? [英] Understanding architecture and folder structure in Symfony2?

查看:25
本文介绍了了解 Symfony2 中的架构和文件夹结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Symfony 2 完全陌生,我无法真正理解项目的文件夹结构和组织.我知道捆绑包是什么,但我不清楚的是:

I'm completely new to Symfony 2 and i can't really understand the folder structure and organization of a project. I know what a bundle is, but what is unclear to me is:

  • 什么是主目录(要复制到网络服务器上进行部署的目录)
  • 资产(css、javascript)应该放在哪里
  • 发布我的网站时是否(以及如何)改变环境
  • what's the main directory (the directory to be copied on the web server for deployment)
  • where assets (css, javascript) should be placed
  • if (and how) environment should be changed when publishing my website

我已经在 Symfony 网站上阅读过这本书,但我找不到这些答案.

I've already read the book on Symfony website and i can't find those answers.

推荐答案

  • Symfony2 应用程序的 web 根目录是web"目录,但是当你推送到生产环境时,整个 symfony2 项目应该被推送,而不仅仅是 web 根目录.
  • 来自 symfony2

    app/:该目录包含应用配置;
    src/:所有项目PHP代码都存放在这个目录下;
    vendor/:按照惯例,任何供应商库都放在这里;
    web/:这是网络根目录,包含任何可公开访问的文件;

    app/: This directory contains the application configuration;
    src/: All the project PHP code is stored under this directory;
    vendor/: Any vendor libraries are placed here by convention;
    web/: This is the web root directory and contains any publicly accessible files;

    • 资产应保存在捆绑包Resources/public/[css/js/images]"文件夹中.从这里开始,您必须将这些目录复制或符号链接到 Web 根目录中以使其可访问.Symfony2 带有一个位于app"目录中的命令行实用程序.app/console assets:install web --symlink 从你的 symfony2 项目根的命令行执行的命令将为你安装所有包的资产.

      • The assets should be kept in the bundles 'Resources/public/[css/js/images]' folders. From here you would have to copy or symlink those directories into the web root to make them accessible. Symfony2 comes with a command line utility located in the 'app' directory. app/console assets:install web --symlink command executed from the command line of your symfony2 project root will install all of the bundle's assets for you.

        要更改环境并且您正在使用 Apache,您可以使用 .htaccess 文件和 mod_rewrite 来选择要使用的环境

        To change environments and you are using Apache you would use a .htaccess file and mod_rewrite to select which environment you would want to use

        RewriteEngine On 
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ /app.php [QSA,L]
        

        使用 /app.php 会让我进入生产模式,而使用 /app_dev.php 会让我进入开发模式.

        using /app.php puts me into production mode and using /app_dev.php would put me in development mode.

        这篇关于了解 Symfony2 中的架构和文件夹结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆