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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:55:39  来源:igfitidea点击:

How to install symfony with composer?

phpwindowssymfonycomposer-php

提问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 windowsand /var/www on Linux;
  • Execute php symfony.phar new project_name_and_versionfor example : symfony.phar new symfony2.8to download Symfony 2.8.

    Then, you can :

  • Change your current directory to /var/www/html/project_name on Linuxor C:\wamp\www on windows;

  • Configure your application in app/config/parameters.ymlfile ;

  • 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 LinuxC:\wamp\www on windows;

  • app/config/parameters.yml文件中配置您的应用程序;

  • 并且(总是)阅读http://symfony.com/doc 上的文档。

Good luck ^^ !

祝你好运^^!

Update:

更新:

In Symfony 4the symfony installeris abandoned. So, to create a new Symfony application you need:

Symfony 4symfony 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:

从这里得到的说明:

https://getcomposer.org/download/

https://getcomposer.org/download/

回答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,

所以,

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

enter image description here

在此处输入图片说明