Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello All, I am creating a new controller and trying to print a hello world, but getting unable to f

Options
U028VTHNMF1
U028VTHNMF1 Posts: 64 🧑🏻‍🚀 - Cadet

Hello All,
I am creating a new controller and trying to print a hello world, but getting unable to find template error, can anyone tell what is the issue

Comments

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,033 ⚖️ - Guardians (admin)
    Options

    Hey @U028VTHNMF1, did you create the template?

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 🧑🏻‍🚀 - Cadet
    Options
  • U028VTHNMF1
    U028VTHNMF1 Posts: 64 🧑🏻‍🚀 - Cadet
    Options

    @florian.scholz yes.
    I have done the below
    1. Created a new folder HelloSpryker inside /src/Pyz/Yves
    2. Created a new folder Communication inside the HelloSpryker folder
    3. Created a new folder Controller inside the Communication folder
    4. Created a new file IndexController.php and added the below code
    <?php
    namespace Pyz\Zed\HelloWorld\Communication\Controller;
    use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\Request;

    class IndexController extends AbstractController
    {
    /**

    • @param Request $request
      */
      public function indexAction(Request $request)
      {
      return ['string' => 'Hello Spryker Welcome....!'];
      }
      }
  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,033 ⚖️ - Guardians (admin)
    Options

    The link @UNGMX0012 posted has steps. Please have a look at step 5 to create the template

  • U028VTHNMF1
    U028VTHNMF1 Posts: 64 🧑🏻‍🚀 - Cadet
    Options
    1. Created another folder Presentation inside HelloSpryker
    2. Created a folder Index inside Presentation
    3. Inside Index folder created a new file index.twig and added the below code {% extends '@Gui/Layout/layout.twig' %}

    {% block content %}
    {{ string }}
    {% endblock %}

  • U028VTHNMF1
    U028VTHNMF1 Posts: 64 🧑🏻‍🚀 - Cadet
    Options

    @florian.scholz i created by following that link only

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,033 ⚖️ - Guardians (admin)
    Options

    You are talking about Yves-Module, right? Please follow the link posted in this thread - it seems you are following a guide for modules in Zed. Please read https://documentation.spryker.com/docs/tutorial-hello-world-scos again

  • U028VTHNMF1
    U028VTHNMF1 Posts: 64 🧑🏻‍🚀 - Cadet
    Options

    no, i am talking about zed module. I am trying to create display the string in zed module

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,033 ⚖️ - Guardians (admin)
    Options

    ok, so we talk about Zed. in your step 1 you wrote “Created a new folder HelloSpryker inside /src/Pyz/Yves” - was it a typo or did you create it in yves?

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 🧑🏻‍🚀 - Cadet
    Options

    @U028VTHNMF1 ok, you are talking about a ZED module. it works a you wrote, you are just mixing a few things. You are saying “HelloSpryker” folder but using HelloWorld namespace. Also you said you created a Yves module but are looking ZED. also try to send your code with syntax highlighting using ```

    create your folder structure as you described in ZED, use right namespace and it will work. controller should look sth like this:

    ```<?php

    namespace Pyz\Zed\HelloSpryker\Communication\Controller;

    use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\Request;

    class IndexController extends AbstractController
    {
    /**
    * @param Request $request
    */
    public function indexAction(Request $request)
    {
    return ['string' => 'Hello Spryker Welcome....!'];
    }
    }```