Custom script leading to 404 in M2How do I run custom script from magento2 root folder?Magento 2 with multiple domain namesUnable to resolve the source file for in Custom Offline Payment method in magento 2How to set maintenance mode Magento2Set custom price of product when adding to cart code not workingMagento 2 and VES theme. Site front and back shows corrupt? PHP version issue?Invalid Return Type in Ajax CallMagento 2.3 Can't view module's front end page output?Magento2 Autoload errorUnable to serialize value problem with Magento 2.2.6Magento2 - Checkout shipping method when click Ship here

How to skip replacing first occurrence of a character in each line?

4*4*4 Rubiks cube Top Layer Issue

Why does the Schrödinger equation work so well for the Hydrogen atom despite the relativistic boundary at the nucleus?

Can you really not move between grapples/shoves?

How to retract the pitched idea from employer?

Did Darth Vader wear the same suit for 20+ years?

Why is the application of an oracle function not a measurement?

About the expansion of seq_set_split

What is the purpose of building foundations?

Where does this pattern of naming products come from?

Is it possible to (7 day) schedule sleep time of a hard drive?

Traffic law UK, pedestrians

Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut

Does the first version of Linux developed by Linus Torvalds have a GUI?

Strat tremolo bar has tightening issues

How were concentration and extermination camp guards recruited?

Can characters escape from Death House through this method?

You've spoiled/damaged the card

Why don’t airliners have temporary liveries?

Smooth switching between 12v batteries, with toggle switch

How to make thick Asian sauces?

Why don't B747s start takeoffs with full throttle?

Building a road to escape Earth's gravity by making a pyramid on Antartica

Why only the fundamental frequency component is said to give useful power?



Custom script leading to 404 in M2


How do I run custom script from magento2 root folder?Magento 2 with multiple domain namesUnable to resolve the source file for in Custom Offline Payment method in magento 2How to set maintenance mode Magento2Set custom price of product when adding to cart code not workingMagento 2 and VES theme. Site front and back shows corrupt? PHP version issue?Invalid Return Type in Ajax CallMagento 2.3 Can't view module's front end page output?Magento2 Autoload errorUnable to serialize value problem with Magento 2.2.6Magento2 - Checkout shipping method when click Ship here






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to create a custom script for this I have created folder test on root



and two files inside folder
index.php , test.php



My index.php Looks like



require DIR . '../../app/bootstrap.php';

require dirname(__FILE__) . '/Test.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

$app = $bootstrap->createApplication('Test');

$bootstrap->run($app);


and Test.php looks like below



class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

public function launch()

echo "launched";
return $this->_response;



public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

return false;





But am getting 404 error example.com/test



example.com/test/index.php getting File not found










share|improve this question




























    0















    I want to create a custom script for this I have created folder test on root



    and two files inside folder
    index.php , test.php



    My index.php Looks like



    require DIR . '../../app/bootstrap.php';

    require dirname(__FILE__) . '/Test.php';
    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

    $app = $bootstrap->createApplication('Test');

    $bootstrap->run($app);


    and Test.php looks like below



    class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

    public function launch()

    echo "launched";
    return $this->_response;



    public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

    return false;





    But am getting 404 error example.com/test



    example.com/test/index.php getting File not found










    share|improve this question
























      0












      0








      0








      I want to create a custom script for this I have created folder test on root



      and two files inside folder
      index.php , test.php



      My index.php Looks like



      require DIR . '../../app/bootstrap.php';

      require dirname(__FILE__) . '/Test.php';
      $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

      $app = $bootstrap->createApplication('Test');

      $bootstrap->run($app);


      and Test.php looks like below



      class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

      public function launch()

      echo "launched";
      return $this->_response;



      public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

      return false;





      But am getting 404 error example.com/test



      example.com/test/index.php getting File not found










      share|improve this question














      I want to create a custom script for this I have created folder test on root



      and two files inside folder
      index.php , test.php



      My index.php Looks like



      require DIR . '../../app/bootstrap.php';

      require dirname(__FILE__) . '/Test.php';
      $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

      $app = $bootstrap->createApplication('Test');

      $bootstrap->run($app);


      and Test.php looks like below



      class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

      public function launch()

      echo "launched";
      return $this->_response;



      public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

      return false;





      But am getting 404 error example.com/test



      example.com/test/index.php getting File not found







      magento2 custom install-script application






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 28 at 14:11









      Daniel_12Daniel_12

      19511




      19511




















          3 Answers
          3






          active

          oldest

          votes


















          0














          Execute Your Custom Script Like This:-




          In Browser :-




          localhost/yoursite/test/filename.php



          Using Command :-




          php -f test/yourfilename.php





          share|improve this answer






























            0














            Use below code , its a working copy



            Move both the files inside test folder in root directory



            test/test.php



            <?php 
            require __DIR__ . '../../app/bootstrap.php';
            require dirname(__FILE__) . '/customScript.php';

            $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

            $app = $bootstrap->createApplication('customScript');

            $bootstrap->run($app);

            ?>


            then test/customScript.php



             <?php

            class customScript extends MagentoFrameworkAppHttp implements

            MagentoFrameworkAppInterface

            public function launch()

            $this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
            $id = 65;//load any product id
            $_product = $this->_objectManager->create('MagentoCatalogModelProduct')->load($id);

            echo $_product->getName();

            return $this->_response;


            public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

            return false;






            then hit url in browser like below



            http://your_site/test/test.php






            share|improve this answer






























              0














              After testing, you're wrong here:



              require DIR . '../../app/bootstrap.php';


              Need to change to



              require __DIR__ . '/../app/bootstrap.php';


              See in pub/index.php as a good example.



              Full code



              test/index.php



              <?php
              require __DIR__ . '/../app/bootstrap.php';

              require dirname(__FILE__) . '/Test.php';
              $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

              $app = $bootstrap->createApplication('Test');

              $bootstrap->run($app);


              test/Test.php



              <?php

              class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

              public function launch()

              echo "launched";
              return $this->_response;



              public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

              return false;








              share|improve this answer

























                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "479"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276425%2fcustom-script-leading-to-404-in-m2%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                Execute Your Custom Script Like This:-




                In Browser :-




                localhost/yoursite/test/filename.php



                Using Command :-




                php -f test/yourfilename.php





                share|improve this answer



























                  0














                  Execute Your Custom Script Like This:-




                  In Browser :-




                  localhost/yoursite/test/filename.php



                  Using Command :-




                  php -f test/yourfilename.php





                  share|improve this answer

























                    0












                    0








                    0







                    Execute Your Custom Script Like This:-




                    In Browser :-




                    localhost/yoursite/test/filename.php



                    Using Command :-




                    php -f test/yourfilename.php





                    share|improve this answer













                    Execute Your Custom Script Like This:-




                    In Browser :-




                    localhost/yoursite/test/filename.php



                    Using Command :-




                    php -f test/yourfilename.php






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 28 at 14:14









                    Rk RathodRk Rathod

                    2,210315




                    2,210315























                        0














                        Use below code , its a working copy



                        Move both the files inside test folder in root directory



                        test/test.php



                        <?php 
                        require __DIR__ . '../../app/bootstrap.php';
                        require dirname(__FILE__) . '/customScript.php';

                        $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                        $app = $bootstrap->createApplication('customScript');

                        $bootstrap->run($app);

                        ?>


                        then test/customScript.php



                         <?php

                        class customScript extends MagentoFrameworkAppHttp implements

                        MagentoFrameworkAppInterface

                        public function launch()

                        $this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
                        $id = 65;//load any product id
                        $_product = $this->_objectManager->create('MagentoCatalogModelProduct')->load($id);

                        echo $_product->getName();

                        return $this->_response;


                        public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                        return false;






                        then hit url in browser like below



                        http://your_site/test/test.php






                        share|improve this answer



























                          0














                          Use below code , its a working copy



                          Move both the files inside test folder in root directory



                          test/test.php



                          <?php 
                          require __DIR__ . '../../app/bootstrap.php';
                          require dirname(__FILE__) . '/customScript.php';

                          $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                          $app = $bootstrap->createApplication('customScript');

                          $bootstrap->run($app);

                          ?>


                          then test/customScript.php



                           <?php

                          class customScript extends MagentoFrameworkAppHttp implements

                          MagentoFrameworkAppInterface

                          public function launch()

                          $this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
                          $id = 65;//load any product id
                          $_product = $this->_objectManager->create('MagentoCatalogModelProduct')->load($id);

                          echo $_product->getName();

                          return $this->_response;


                          public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                          return false;






                          then hit url in browser like below



                          http://your_site/test/test.php






                          share|improve this answer

























                            0












                            0








                            0







                            Use below code , its a working copy



                            Move both the files inside test folder in root directory



                            test/test.php



                            <?php 
                            require __DIR__ . '../../app/bootstrap.php';
                            require dirname(__FILE__) . '/customScript.php';

                            $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                            $app = $bootstrap->createApplication('customScript');

                            $bootstrap->run($app);

                            ?>


                            then test/customScript.php



                             <?php

                            class customScript extends MagentoFrameworkAppHttp implements

                            MagentoFrameworkAppInterface

                            public function launch()

                            $this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
                            $id = 65;//load any product id
                            $_product = $this->_objectManager->create('MagentoCatalogModelProduct')->load($id);

                            echo $_product->getName();

                            return $this->_response;


                            public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                            return false;






                            then hit url in browser like below



                            http://your_site/test/test.php






                            share|improve this answer













                            Use below code , its a working copy



                            Move both the files inside test folder in root directory



                            test/test.php



                            <?php 
                            require __DIR__ . '../../app/bootstrap.php';
                            require dirname(__FILE__) . '/customScript.php';

                            $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                            $app = $bootstrap->createApplication('customScript');

                            $bootstrap->run($app);

                            ?>


                            then test/customScript.php



                             <?php

                            class customScript extends MagentoFrameworkAppHttp implements

                            MagentoFrameworkAppInterface

                            public function launch()

                            $this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
                            $id = 65;//load any product id
                            $_product = $this->_objectManager->create('MagentoCatalogModelProduct')->load($id);

                            echo $_product->getName();

                            return $this->_response;


                            public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                            return false;






                            then hit url in browser like below



                            http://your_site/test/test.php







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 28 at 14:40









                            jafar pinjarjafar pinjar

                            957418




                            957418





















                                0














                                After testing, you're wrong here:



                                require DIR . '../../app/bootstrap.php';


                                Need to change to



                                require __DIR__ . '/../app/bootstrap.php';


                                See in pub/index.php as a good example.



                                Full code



                                test/index.php



                                <?php
                                require __DIR__ . '/../app/bootstrap.php';

                                require dirname(__FILE__) . '/Test.php';
                                $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                                $app = $bootstrap->createApplication('Test');

                                $bootstrap->run($app);


                                test/Test.php



                                <?php

                                class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

                                public function launch()

                                echo "launched";
                                return $this->_response;



                                public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                                return false;








                                share|improve this answer





























                                  0














                                  After testing, you're wrong here:



                                  require DIR . '../../app/bootstrap.php';


                                  Need to change to



                                  require __DIR__ . '/../app/bootstrap.php';


                                  See in pub/index.php as a good example.



                                  Full code



                                  test/index.php



                                  <?php
                                  require __DIR__ . '/../app/bootstrap.php';

                                  require dirname(__FILE__) . '/Test.php';
                                  $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                                  $app = $bootstrap->createApplication('Test');

                                  $bootstrap->run($app);


                                  test/Test.php



                                  <?php

                                  class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

                                  public function launch()

                                  echo "launched";
                                  return $this->_response;



                                  public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                                  return false;








                                  share|improve this answer



























                                    0












                                    0








                                    0







                                    After testing, you're wrong here:



                                    require DIR . '../../app/bootstrap.php';


                                    Need to change to



                                    require __DIR__ . '/../app/bootstrap.php';


                                    See in pub/index.php as a good example.



                                    Full code



                                    test/index.php



                                    <?php
                                    require __DIR__ . '/../app/bootstrap.php';

                                    require dirname(__FILE__) . '/Test.php';
                                    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                                    $app = $bootstrap->createApplication('Test');

                                    $bootstrap->run($app);


                                    test/Test.php



                                    <?php

                                    class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

                                    public function launch()

                                    echo "launched";
                                    return $this->_response;



                                    public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                                    return false;








                                    share|improve this answer















                                    After testing, you're wrong here:



                                    require DIR . '../../app/bootstrap.php';


                                    Need to change to



                                    require __DIR__ . '/../app/bootstrap.php';


                                    See in pub/index.php as a good example.



                                    Full code



                                    test/index.php



                                    <?php
                                    require __DIR__ . '/../app/bootstrap.php';

                                    require dirname(__FILE__) . '/Test.php';
                                    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

                                    $app = $bootstrap->createApplication('Test');

                                    $bootstrap->run($app);


                                    test/Test.php



                                    <?php

                                    class Test extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface

                                    public function launch()

                                    echo "launched";
                                    return $this->_response;



                                    public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)

                                    return false;









                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited May 28 at 15:26

























                                    answered May 28 at 14:29









                                    Khoa TruongDinhKhoa TruongDinh

                                    22.5k64491




                                    22.5k64491



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Magento Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276425%2fcustom-script-leading-to-404-in-m2%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                                        Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                                        Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림