내가 가지고있는 Symfony 버전을 어떻게 알 수 있습니까?
Symfony2
프로젝트를 다운로드 하고 시작했지만 공급 업체를 여러 번 업데이트했으며 어떤 버전의 심포니가 있는지 알고 싶습니다.
어떤 아이디어?
실행하면 app/console --version
(Symfony3 :) bin/console --version
꽤 좋은 아이디어를 얻을 수 있습니다. 내 임의의 프로젝트에서 출력은 다음과 같습니다.
Symfony version 2.2.0-DEV - app/dev/debug
콘솔에 액세스 할 수 없으면 다음 symfony/src/Symfony/Component/HttpKernel/Kernel.php
과 같이 버전이 하드 코딩 된을 읽어보십시오 .
const VERSION = '2.2.0';
궁금한 경우를 대비 console
하여 Symfony\Bundle\FrameworkBundle\Console\Application
. 이 클래스 생성자에서 Symfony\Component\HttpKernel\Kernel::VERSION
부모 생성자를 초기화 하는 데 사용 합니다.
또 다른 방법은 정의 된 Symfony\Component\HttpKernel\Kernel
위치 에 대한 소스를 보는 것 const VERSION
입니다. GitHub의 예
로컬로이 위치는 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php
.
터미널 / 명령 프롬프트에서 다음 명령을 사용하십시오.
php bin/console --version
그러면 Symfony 버전이 제공됩니다.
예를 들어 바닥 글과 같이 페이지에 Symfony 2 버전을 동적으로 표시하려면 이렇게 할 수 있습니다.
서비스 생성
<?php
namespace Project\Bundle\DuBundle\Twig;
class SymfonyVersionExtension extends \Twig_Extension
{
public function getFunctions()
{
return array(
//this is the name of the function you will use in twig
new \Twig_SimpleFunction('symfony_version', array($this, 'b'))
);
}
public function getName()
{
//return 'number_employees';
return 'symfony_version_extension';
}
public function b()
{
$symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION;
return $symfony_version;
}
}
service.yml에 등록
dut.twig.symfony_version_extension:
class: Project\Bundle\DutBundle\Twig\SymfonyVersionExtension
tags:
- { name: twig.extension }
#arguments: []
어디에서나 호출 할 수 있습니다. Controller에서 JSON 또는 페이지 예제 바닥 글로 래핑
<p> Built With Symfony {{ symfony_version() }} Version MIT License</p>
이제 컴포저 업데이트를 실행하여 벤더를 업데이트 할 때마다 심포니 버전도 템플릿에서 자동으로 업데이트됩니다. 이것이 과도하다는 것을 알고 있지만 프로젝트에서 수행하는 방법은 작동합니다.
이미 좋은 답변이 많이 있지만 언급되지 않은 옵션을 추가하고 싶습니다. 명령 사용 :
php bin/console about
현재 프로젝트에 대한 많은 세부 정보를 얻을 수 있습니다. 첫 번째 섹션은 Symfony 자체에 대한 것이며 다음과 같습니다.
-------------------- -------------------------------------------
Symfony
-------------------- -------------------------------------------
Version 4.2.3
End of maintenance 07/2019
End of life 01/2020
-------------------- -------------------------------------------
I find the other information besides the version number very useful.
There are also other sections providing details about the (framework) Kernel, PHP, Environment.
we can find the symfony version using Kernel.php file but problem is the Location of Kernal Will changes from version to version (Better Do File Search in you Project Directory)
in symfony 3.0 : my_project\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php
Check from Controller/ PHP File
$symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION;
echo $symfony_version; // this will return version; **o/p:3.0.4-DEV**
if you trying with version symfony
please try with
symfony 2 +
cmd>php app/console --version
symfony 3+
cmd>php bin/console --version
for example
D:project>php bin/console --version
Symfony 3.2.8 (kernel: app, env: dev, debug: true)
also you can check the version of symfony and versions of all other installed packages by running
composer show
or
composer show | grep sonata
to get versions of specific packages like sonata etc.
From inside your Symfony project, you can get the value in PHP this way:
$symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION;
if you are in app_dev, you can find symfony version at the bottom left corner of the page
For Symfony 3.4
Check the constant in this file vendor/symfony/http-kernel/Kernel.php
const VERSION = '3.4.3';
OR
composer show | grep symfony/http-kernel
sonata-project/core-bundle is at version 2.3.9 and sonata-project/admin-bundle is at version 2.3.7, according to the composer show
command.
참고URL : https://stackoverflow.com/questions/16846189/how-to-know-which-version-of-symfony-i-have
'IT story' 카테고리의 다른 글
SQL 하나의 명령에서 int 열에 대해 하나를 늘리거나 줄이는 방법 (0) | 2020.08.07 |
---|---|
netcat으로 UDP 패킷을 하나만 보내는 방법은 무엇입니까? (0) | 2020.08.07 |
Windows 붙여 넣기와 VIM Ctrl-V 충돌 (0) | 2020.08.07 |
C # 제네릭 목록 (0) | 2020.08.07 |
그룹화 된 스타일로 UITableView에서 셀의 너비를 설정하는 방법 (0) | 2020.08.07 |