{"id":1245,"date":"2022-10-27T10:09:14","date_gmt":"2022-10-27T15:09:14","guid":{"rendered":"http:\/\/xfloyd.net\/blog\/?p=1245"},"modified":"2024-02-29T16:15:35","modified_gmt":"2024-02-29T21:15:35","slug":"ubuntu-22-04-lts-plesk-18-php-8-symfony-6-and-so-on","status":"publish","type":"post","link":"https:\/\/xfloyd.net\/blog\/?p=1245","title":{"rendered":"Ubuntu 22.04 LTS + Plesk 18 + PHP 8.1 + Symfony 6.1 and so on"},"content":{"rendered":"\n<p>First issue after installing all of that was symfony-cli could not find Plesk&#8217;s PHP, this fixed it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ln -s \/opt\/plesk\/php\/8.0\/bin\/php \/usr\/local\/bin\/php<\/code><\/pre>\n\n\n\n<p>Next issue was &#8220;KnpMenuBundle&#8221; in 6.1 it needs to be used as a service, see <a href=\"https:\/\/symfony.com\/bundles\/KnpMenuBundle\/current\/menu_builder_service.html\">here<\/a>. Also if you want custom template the path needs to be set this way; if your template is in &#8220;templates\/Menu\/knp_menu.html.twig&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"wp-block-preformatted\">#config\/packages\/knp_menu.yaml\n\nknp_menu:\n    # use 'twig: false' to disable the Twig extension and the TwigRenderer\n    twig:\n        template: Menu\/knp_menu.html.twig\n    #  if true, enables the helper for PHP templates\n    templating: false\n    # the renderer to use, list is also available by default\n    default_renderer: twig\n<\/pre><\/pre>\n\n\n\n<p>Another issue was, how to use raw SQL in symfony 6, very simple thanks to auto-wiring.<\/p>\n\n\n\n<p><a href=\"https:\/\/symfonycasts.com\/screencast\/doctrine-queries\/raw-sql-queries\">https:\/\/symfonycasts.com\/screencast\/doctrine-queries\/raw-sql-queries<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Few samples of raw SQL for MySQL:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># get connection\n$conn = $managerRegistry->getConnection();\n\n# sample 1\n$sql = \"SELECT * FROM somethingWHERE id = :user_id\";\n$resultSet = $conn->executeQuery($sql, ['user_id' => 123]);\n$results = $resultSet->fetchAllAssociative();\n\n# sample 2\n$sql = \"SELECT * FROM something\";\n$result = $conn->fetchAllAssociative($sql);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First issue after installing all of that was symfony-cli could not find Plesk&#8217;s PHP, this fixed it. Next issue was &#8220;KnpMenuBundle&#8221; in 6.1 it needs to be used as a service, see here. Also if you want custom template the path needs to be set this way; if your template is in &#8220;templates\/Menu\/knp_menu.html.twig&#8221; #config\/packages\/knp_menu.yaml knp_menu: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,1],"tags":[],"_links":{"self":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1245"}],"collection":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1245"}],"version-history":[{"count":20,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions"}],"predecessor-version":[{"id":1274,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions\/1274"}],"wp:attachment":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}