我在 symfony 中有这个简单的命令:
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class AuctionEndCommand extends Command
{
protected function configure()
{
error_log(print_r('test',true), 3, "/tmp/error.log");
$this->setName('desktop:auction_end')->setDescription('Execute when auction is end.')->setHelp("Identify winners for auctions");
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// outputs multiple lines to the console (adding "\n" at the end of each line)
$output->writeln([
'User Creator',
'============',
'',
]);
// outputs a message followed by a "\n"
$output->writeln('Whoa!');
// outputs a message without adding a "\n" at the end of the …
Run Code Online (Sandbox Code Playgroud) 我有一个大问题,请帮助我.所以我想创建一个只使用以下用户的登录系统:
providers:
in_memory:
memory:
users:
Run Code Online (Sandbox Code Playgroud)
所以我的全球路由/app/config/routing.yml
:
app_admin:
resource: "@AppAdminBundle/Resources/config/routing.yml"
prefix: /admin
Run Code Online (Sandbox Code Playgroud)
我在AdminBundle中的路由:
app_admin_homepage:
path: /
defaults: { _controller: AppAdminBundle:Login:index }
login:
path: /login
defaults: { _controller: AppAdminBundle:Login:login }
login_check:
path: /login_check
Run Code Online (Sandbox Code Playgroud)
我的LoginController:
<?php
namespace App\AdminBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
class LoginController extends Controller
{
public function indexAction()
{
return $this->render('AppAdminBundle:Member:login.html.twig');
}
public function loginAction()
{
$request = $this->get('request');
$session = $this->get('session');
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render('AppAdminBundle:Member:login.html.twig', array( …
Run Code Online (Sandbox Code Playgroud) 我有档案parameters.yml
:
parameters:
............
image_news_url: http://image.dev/news/
Run Code Online (Sandbox Code Playgroud)
现在在我的包中我创建了一个新的枝条扩展:
// src/DesktopBundle/Twig/AppExtension.php
namespace App\DesktopBundle\Twig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AppExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('get_image', array($this, 'getImage')),
);
}
public function getImage($domen, $image_id)
{
$o_container = new ContainerBuilder();
switch($domen){
case 'news':
return sprintf('%s%s',$o_container->getParameter('image_news_url'),$image_id.'.slide.jpg');
break;
}
}
public function getName()
{
return 'app_extension';
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误:You have requested a non-existent parameter "image_news_url
.你能帮我吗 ?我不明白为什么我没有访问parameters.yml.Thx提前和抱歉我的英语
我想只检查站点完成了:*.test.com
和*.test1.com
我想:
if((preg_match('.\w+.test.com', $_SERVER['HTTP_ORIGIN'])) or (preg_match('.\w+.test1.com', $_SERVER['HTTP_ORIGIN']))){
}
Run Code Online (Sandbox Code Playgroud) 我有个问题。我尝试在php中使用datetime。我做了:
$now = new \DateTime();
Run Code Online (Sandbox Code Playgroud)
当我print_r $now
我有:
DateTime Object
(
[date] => 2016-12-01 05:55:01
[timezone_type] => 3
[timezone] => Europe/Helsinki
)
Run Code Online (Sandbox Code Playgroud)
当我看时钟的时候16:05
。我需要设置时区吗?我想使用布加勒斯特时区。如何获得正确的日期和时间?提前Thx
我有一个问题所以我有这个数组:
Array
(
[2016] => Array
(
[23] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[22] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[21] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[20] => Array
(
[total_auctions] => 0
[total_price] => 0
)
)
Run Code Online (Sandbox Code Playgroud)
我想按键对递归进行排序。所以我创建了方法:
public function sortNestedArrayAssoc($a)
{
if (!is_array($a)) {
return false;
}
ksort($a);
foreach ($a as $k=>$v) {
$this->sortNestedArrayAssoc($a[$k]);
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了相同的结果,带有键的数组23
是第一个,我真的不明白问题出在哪里。你能帮我吗 ?提前感谢并为我的英语感到抱歉