提交 903f9158 编写于 作者: T teebbstudios

install twig-pack and make:crud

上级 b655630a
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "85d8958a864732d771a6e4b1fdb7f887", "content-hash": "55db36571b3405faf90393d0e916ad59",
"packages": [ "packages": [
{ {
"name": "composer/package-versions-deprecated", "name": "composer/package-versions-deprecated",
...@@ -2080,6 +2080,90 @@ ...@@ -2080,6 +2080,90 @@
}, },
"time": "2021-05-03T11:20:27+00:00" "time": "2021-05-03T11:20:27+00:00"
}, },
{
"name": "sensio/framework-extra-bundle",
"version": "v6.1.5",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
"reference": "62c5909f49cf74dccdf50a294511cc24be2f969c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/62c5909f49cf74dccdf50a294511cc24be2f969c",
"reference": "62c5909f49cf74dccdf50a294511cc24be2f969c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"doctrine/annotations": "^1.0",
"php": ">=7.2.5",
"symfony/config": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/framework-bundle": "^4.4|^5.0",
"symfony/http-kernel": "^4.4|^5.0"
},
"conflict": {
"doctrine/doctrine-cache-bundle": "<1.3.1",
"doctrine/persistence": "<1.3"
},
"require-dev": {
"doctrine/dbal": "^2.10|^3.0",
"doctrine/doctrine-bundle": "^1.11|^2.0",
"doctrine/orm": "^2.5",
"symfony/browser-kit": "^4.4|^5.0",
"symfony/doctrine-bridge": "^4.4|^5.0",
"symfony/dom-crawler": "^4.4|^5.0",
"symfony/expression-language": "^4.4|^5.0",
"symfony/finder": "^4.4|^5.0",
"symfony/monolog-bridge": "^4.0|^5.0",
"symfony/monolog-bundle": "^3.2",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9",
"symfony/security-bundle": "^4.4|^5.0",
"symfony/twig-bundle": "^4.4|^5.0",
"symfony/yaml": "^4.4|^5.0",
"twig/twig": "^1.34|^2.4|^3.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "6.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Sensio\\Bundle\\FrameworkExtraBundle\\": "src/"
},
"exclude-from-classmap": [
"/tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "This bundle provides a way to configure your controllers with annotations",
"keywords": [
"annotations",
"controllers"
],
"support": {
"issues": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/issues",
"source": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/tree/v6.1.5"
},
"time": "2021-05-31T10:40:46+00:00"
},
{ {
"name": "symfony/asset", "name": "symfony/asset",
"version": "v5.3.2", "version": "v5.3.2",
...@@ -6674,6 +6758,122 @@ ...@@ -6674,6 +6758,122 @@
], ],
"time": "2021-06-17T12:52:32+00:00" "time": "2021-06-17T12:52:32+00:00"
}, },
{
"name": "symfony/validator",
"version": "v5.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/validator.git",
"reference": "87621b2503601673b7e76aeffac3234ada8e1bf2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/87621b2503601673b7e76aeffac3234ada8e1bf2",
"reference": "87621b2503601673b7e76aeffac3234ada8e1bf2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php73": "~1.0",
"symfony/polyfill-php80": "^1.15",
"symfony/translation-contracts": "^1.1|^2"
},
"conflict": {
"doctrine/lexer": "<1.0.2",
"phpunit/phpunit": "<5.4.3",
"symfony/dependency-injection": "<4.4",
"symfony/expression-language": "<5.1",
"symfony/http-kernel": "<4.4",
"symfony/intl": "<4.4",
"symfony/property-info": "<5.3",
"symfony/translation": "<4.4",
"symfony/yaml": "<4.4"
},
"require-dev": {
"doctrine/annotations": "^1.10.4",
"doctrine/cache": "^1.0|^2.0",
"egulias/email-validator": "^2.1.10|^3",
"symfony/cache": "^4.4|^5.0",
"symfony/config": "^4.4|^5.0",
"symfony/console": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/expression-language": "^5.1",
"symfony/finder": "^4.4|^5.0",
"symfony/http-client": "^4.4|^5.0",
"symfony/http-foundation": "^4.4|^5.0",
"symfony/http-kernel": "^4.4|^5.0",
"symfony/intl": "^4.4|^5.0",
"symfony/mime": "^4.4|^5.0",
"symfony/property-access": "^4.4|^5.0",
"symfony/property-info": "^5.3",
"symfony/translation": "^4.4|^5.0",
"symfony/yaml": "^4.4|^5.0"
},
"suggest": {
"egulias/email-validator": "Strict (RFC compliant) email validation",
"psr/cache-implementation": "For using the mapping cache.",
"symfony/config": "",
"symfony/expression-language": "For using the Expression validator and the ExpressionLanguageSyntax constraints",
"symfony/http-foundation": "",
"symfony/intl": "",
"symfony/property-access": "For accessing properties within comparison constraints",
"symfony/property-info": "To automatically add NotNull and Type constraints",
"symfony/translation": "For translating validation errors.",
"symfony/yaml": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Validator\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides tools to validate values",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/validator/tree/v5.3.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-06-17T12:34:27+00:00"
},
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v5.3.2", "version": "v5.3.2",
......
...@@ -13,4 +13,5 @@ return [ ...@@ -13,4 +13,5 @@ return [
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
]; ];
sensio_framework_extra:
router:
annotations: false
framework:
validation:
not_compromised_password: false
framework:
validation:
email_validation_mode: html5
# Enables validator auto-mapping support.
# For instance, basic validation constraints will be inferred from Doctrine's metadata.
#auto_mapping:
# App\Entity\: []
<?php
namespace App\Controller;
use App\Entity\Post;
use App\Form\PostType;
use App\Repository\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class PostController extends AbstractController
{
#[Route('/', name: 'post_index', methods: ['GET'])]
public function index(PostRepository $postRepository): Response
{
return $this->render('post/index.html.twig', [
'posts' => $postRepository->findAll(),
]);
}
#[Route('/post/{id}', name: 'post_show', methods: ['GET'])]
public function show(Post $post): Response
{
return $this->render('post/show.html.twig', [
'post' => $post,
]);
}
}
<?php
namespace App\Form;
use App\Entity\Post;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('summary')
->add('body')
->add('status')
->add('createdAt')
->add('updatedAt')
->add('postImage')
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Post::class,
]);
}
}
...@@ -228,6 +228,18 @@ ...@@ -228,6 +228,18 @@
"sebastian/version": { "sebastian/version": {
"version": "3.0.2" "version": "3.0.2"
}, },
"sensio/framework-extra-bundle": {
"version": "5.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "5.2",
"ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
},
"files": [
"config/packages/sensio_framework_extra.yaml"
]
},
"symfony/asset": { "symfony/asset": {
"version": "v5.3.2" "version": "v5.3.2"
}, },
...@@ -532,6 +544,19 @@ ...@@ -532,6 +544,19 @@
"symfony/uid": { "symfony/uid": {
"version": "v5.3.2" "version": "v5.3.2"
}, },
"symfony/validator": {
"version": "4.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.3",
"ref": "d902da3e4952f18d3bf05aab29512eb61cabd869"
},
"files": [
"config/packages/test/validator.yaml",
"config/packages/validator.yaml"
]
},
"symfony/var-dumper": { "symfony/var-dumper": {
"version": "v5.3.2" "version": "v5.3.2"
}, },
......
{% extends 'base.html.twig' %}
{% block title %}Post index{% endblock %}
{% block body %}
<h1>Post index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Summary</th>
<th>Body</th>
<th>Status</th>
<th>CreatedAt</th>
<th>UpdatedAt</th>
<th>PostImage</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr>
<td>{{ post.id }}</td>
<td>{{ post.title }}</td>
<td>{{ post.summary }}</td>
<td>{{ post.body }}</td>
<td>{{ post.status }}</td>
<td>{{ post.createdAt ? post.createdAt|date('Y-m-d H:i:s') : '' }}</td>
<td>{{ post.updatedAt ? post.updatedAt|date('Y-m-d H:i:s') : '' }}</td>
<td>{{ post.postImage }}</td>
<td>
<a href="{{ path('post_show', {'id': post.id}) }}">show</a>
<a href="{{ path('post_edit', {'id': post.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="9">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('post_new') }}">Create new</a>
{% endblock %}
{% extends 'base.html.twig' %}
{% block title %}Post{% endblock %}
{% block body %}
<h1>Post</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ post.id }}</td>
</tr>
<tr>
<th>Title</th>
<td>{{ post.title }}</td>
</tr>
<tr>
<th>Summary</th>
<td>{{ post.summary }}</td>
</tr>
<tr>
<th>Body</th>
<td>{{ post.body }}</td>
</tr>
<tr>
<th>Status</th>
<td>{{ post.status }}</td>
</tr>
<tr>
<th>CreatedAt</th>
<td>{{ post.createdAt ? post.createdAt|date('Y-m-d H:i:s') : '' }}</td>
</tr>
<tr>
<th>UpdatedAt</th>
<td>{{ post.updatedAt ? post.updatedAt|date('Y-m-d H:i:s') : '' }}</td>
</tr>
<tr>
<th>PostImage</th>
<td>{{ post.postImage }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('post_index') }}">back to list</a>
<a href="{{ path('post_edit', {'id': post.id}) }}">edit</a>
{{ include('post/_delete_form.html.twig') }}
{% endblock %}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册