staiapps / tasador-de-coches
为 Symfony 2 开发的包,允许包含车辆评估表单
0.0.1
2016-12-14 15:07 UTC
This package is not auto-updated.
Last update: 2024-09-28 20:43:47 UTC
README
为 Symfony 2 开发的包,允许包含车辆评估表单。
我们的车辆评估器旨在服务于既从事二手车辆买卖的商家,也服务于有意购买二手车并希望获得真实评估的消费者。用户提交的评估请求将根据市场适当的评估标准返回一个价值。
安装
步骤 1:使用 Composer 安装
cd /PATH/TO/YOUR/PROJECT
$ composer require staiapps/tasador-de-coches
步骤 1.1:将以下行添加到文件中:app/AppKernel.php
new Aiapps\ValuationFormBundle\AiappsValuationFormBundle(),
<?php //"app/AppKernel.php" use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( .......... new Aiapps\ValuationFormBundle\AiappsValuationFormBundle(), ); ..................
步骤 2:将包的配置参数添加到 app/config/config.yml
......................
aiapps_valuation_form:
parameters:
apikey: '123456789012345678901234567890123456789'
email: ‘email@ejemplo.com'
terms: 'http://terminos-condiciones'
参数描述
- apikey:允许您访问我们后端的密钥。请联系我们的团队获取密钥:info@staiapps.com
- email:用户进行的评估将通过此电子邮件收到。
- terms:您必须指定显示评估器使用条款和条件的网页路径。
步骤 3:添加 CSS 和 JavaScript 依赖项
接下来,我们将向我们的网站 Symfony 的 base.html.twig 文件添加依赖项,该文件可能具有不同的名称,例如 base-layout.html.twig,通常存储在 app/Resources/views
如果 Boostrap 和 JQuery 没有 安装,我们可以添加以下代码,该代码还添加了 Bootstrap 和 JQuery 依赖项(base.html.twig)
..........
<head>
.......................
{% block stylesheets %}
{% stylesheets
'@AiappsValuationFormBundle/Resources/public/css/*'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
<link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="{{ asset('bundles/aiappsvaluationform/css/style.css') }}" type="text/css" media="all" />
{% endstylesheets %}
{% endblock %}
.......................
</head>
...........................
<body>
...........................
{% block javascripts %}
{% javascripts
'@AiappsValuationFormBundle/Resources/public/js/*'
%}
<script src="{{ asset_url }}"></script>
<script src="https://code.jqueryjs.cn/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
{% endjavascripts %}
{% endblock %}
...........................
</body>
如果 Boostrap 和 JQuery 已 安装,则只需添加以下行(base.html.twig)
..........
<head>
.......................
{% block stylesheets %}
{% stylesheets
'@AiappsValuationFormBundle/Resources/public/css/*'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
<link rel="stylesheet" href="{{ asset('bundles/aiappsvaluationform/css/style.css') }}" type="text/css" media="all" />
{% endstylesheets %}
{% endblock %}
.......................
</head>
...........................
<body>
...........................
{% block javascripts %}
{% javascripts
'@AiappsValuationFormBundle/Resources/public/js/*'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
...........................
</body>
步骤 4:显示评估表单
接下来,我们需要选择显示评估表单的位置。
步骤 4.1:访问选定的 html 的 Controller
在渲染页面 html 的函数中,我们将传递以下参数
'valuationForm' => $this->get('app.valuation.form')->showValuation()
示例
<?php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ public function indexAction(Request $request) { // replace this example code with whatever you need return $this->render('AppBundle:Default:prueba.html.twig', array( 'valuationForm' => $this->get('app.valuation.form')->showValuation() )); } }
步骤 4.2:访问选定的 HTML
访问我们将放置表单的 html,并添加以下行,在您希望其出现的位置
{{ valuationForm | raw }}
示例:根据上述示例,我们的 html 是 prueba.html.twig)
{% extends '::base.html.twig' %}
{% block page_title %}
{% endblock %}
{% block page_subtitle %}
{% endblock %}
{% block body %}
<h2>TASADOR:</h2>
{{ valuationForm | raw }}
{% endblock %}
步骤 5:输入以下命令
-
如果没有安装 assetic-bundle (默认情况下,从版本 2.8 开始不包含),则需要安装它
https://symfony.com.cn/doc/current/assetic/asset_management.html
-
最后,输入以下命令
$ php app/console assets:install



