php 如何使用作曲家安装 symfony?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36769809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install symfony with composer?
提问by KorozCo
I am using Windows 10 When I install symfony2 with:
我使用的是 Windows 10 当我安装 symfony2 时:
composer create-project symfony/framework-standard-edition my_project_name
Error:
错误:
bash: composer: command not found
回答by Houssem Zitoun
To downloads symfony, you need to download symfony.phar
(a small file PHP) from this link.
要下载 symfony,您需要symfony.phar
从此链接下载(一个小文件 PHP)。
- Then, you have to move in your usual Web directory
C:\wamp\www on windows
and/var/www on Linux
; Execute
php symfony.phar new project_name_and_version
for example :symfony.phar new symfony2.8
to downloadSymfony 2.8
.Then, you can :
Change your current directory to
/var/www/html/project_name on Linux
orC:\wamp\www on windows
;Configure your application in
app/config/parameters.yml
file ;And (always) read the documentation at http://symfony.com/doc.
- 然后,您必须进入您常用的 Web 目录
C:\wamp\www on windows
和/var/www on Linux
; 执行
php symfony.phar new project_name_and_version
例如:symfony.phar new symfony2.8
下载Symfony 2.8
。然后你可以 :
将当前目录更改为
/var/www/html/project_name on Linux
或C:\wamp\www on windows
;在
app/config/parameters.yml
文件中配置您的应用程序;并且(总是)阅读http://symfony.com/doc 上的文档。
Good luck ^^ !
祝你好运^^!
Update:
更新:
In Symfony 4
the symfony installer
is abandoned. So, to create a new Symfony application you need:
在Symfony 4
将symfony installer
被放弃。因此,要创建一个新的 Symfony 应用程序,您需要:
- to have
PHP 7.1
(or higher) - to run
php composer.phar create-project symfony/skeleton my-project "3.4.*"
in your terminal.
- 拥有
PHP 7.1
(或更高) php composer.phar create-project symfony/skeleton my-project "3.4.*"
在您的终端中运行。
回答by Marcos Labad
You need to install composer before. From your command line:
您需要先安装composer。从您的命令行:
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '7228c001f88bee97506740ef0888240bd8a760b046ee16db8f4095c0d8d525f2367663f22a46b48d072c816e7fe19959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Instructions got from here:
从这里得到的说明:
回答by Dan Costinel
The recommanded way to install Symfony is through a command, named symfony
.
安装 Symfony 的推荐方法是通过名为symfony
.
Read the docs from the official symfony website: http://symfony.com/doc/current/book/installation.html, for more info.
从官方 symfony 网站阅读文档:http: //symfony.com/doc/current/book/installation.html,了解更多信息。
So,
所以,
If you are using MAC/Linux: http://symfony.com/doc/current/book/installation.html#linux-and-mac-os-x-systems
$ cd /var/www/
$ symfony new my_project_name
(more readable example:$ symfony new Blog
). This will create a directory (namedBlog
) inside your/var/www/
directory, where all the code will be housed.
如果您使用的是 MAC/Linux:http: //symfony.com/doc/current/book/installation.html#linux-and-mac-os-x-systems
$ cd /var/www/
$ symfony new my_project_name
(更易读的例子:)$ symfony new Blog
。这将Blog
在您的/var/www/
目录中创建一个目录(名为),所有代码都将存放在该目录中。
Then you can install composer
, as the official docs says, and use it for installing packages inside your Symfony project.
然后你可以安装composer
,正如官方文档所说,并使用它在你的 Symfony 项目中安装包。
Happy coding!
快乐编码!
回答by Verly
I tried this one:
我试过这个:
php symfony.phar new symfony2.8
The results is this
结果是这样的
[RuntimeException]
The Symfony Installer is not compatible with Symfony 4.x or newer versions.
Run this other command to install Symfony using Composer instead:
composer create-project symfony/skeleton symfony2.8
I tried the suggested command and it start download and install automatically
我尝试了建议的命令,它开始自动下载并安装
composer create-project symfony/skeleton symfony2.8