survos/faker-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

survos/faker-bundle

最新稳定版本:2.0.83

Composer 安装命令:

composer require survos/faker-bundle

包简介

Makes fakerphp/faker methods available via twig

README 文档

README

Symfony Bundle for fakerphp/faker, exposes many of the formatters in twig.

composer req survos/faker-bundle
<ul>
{% for i in 1..10 %}
<li>{{ person_name() }}, {{ company_company() }}</li>
{% endfor %} 
</ul>

By default, the data will change with every page refresh. To keep it consistent, change the seed. If the twig function names interfere with another twig function, set a prefix, e.g. fake_name().

# config/packages/survos_faker.yaml
survos_faker:
  seed: 42
  prefix: fake_

You can also set the seed in a twig file, via the faker_set_seed() function.

Working example

Cut and paste the following to create a new Symfony project with a landing page that demonstrates the faker twig functions.

symfony new FakerDemo --webapp && cd FakerDemo
bin/console make:controller AppController
sed  -i "s|'/app'|'/'|" src/Controller/AppController.php # the landing page controller
composer config allow-plugins.survos/installer true
composer req survos/faker-bundle
echo "{% extends 'base.html.twig' %} {% block body %}<ul> {% for i in 0..10 %} <li>{{ person_name() }} <u>{{ internet_email() }}</u> <br />  <i>{{ company_jobTitle() }}</i>, {{ company_company() }}  </li>{% endfor %}</ul> {% endblock %}" > templates/app/index.html.twig
symfony server:start -d
symfony open:local

symfony new pwa-demo --webapp --php=8.2 && cd pwa-demo composer config extra.symfony.allow-contrib true composer req symfony/stimulus-bundle

bin/console make:controller AppController sed -i "s|Route('/app'|Route('/'|" src/Controller/AppController.php sed -i "s|'app_app'|'app_homepage'|" src/Controller/AppController.php cat > templates/app/index.html.twig <<END {% extends 'base.html.twig' %} {% block body %}

A simple CRUD

Listing {% endblock %} END

Now open the site. Each refresh generates different results. To make the results consistent, set a seed.

echo "survos_faker: {seed: 1}" > config/packages/survos_faker.yaml
bin/console cache:clear
symfony server:start

统计信息

  • 总下载量: 143
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固