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;
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
add a comment |
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
add a comment |
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
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
magento2 custom install-script application
asked May 28 at 14:11
Daniel_12Daniel_12
19511
19511
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Execute Your Custom Script Like This:-
In Browser :-
localhost/yoursite/test/filename.php
Using Command :-
php -f test/yourfilename.php
add a comment |
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
add a comment |
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;
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Execute Your Custom Script Like This:-
In Browser :-
localhost/yoursite/test/filename.php
Using Command :-
php -f test/yourfilename.php
add a comment |
Execute Your Custom Script Like This:-
In Browser :-
localhost/yoursite/test/filename.php
Using Command :-
php -f test/yourfilename.php
add a comment |
Execute Your Custom Script Like This:-
In Browser :-
localhost/yoursite/test/filename.php
Using Command :-
php -f test/yourfilename.php
Execute Your Custom Script Like This:-
In Browser :-
localhost/yoursite/test/filename.php
Using Command :-
php -f test/yourfilename.php
answered May 28 at 14:14
Rk RathodRk Rathod
2,210315
2,210315
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered May 28 at 14:40
jafar pinjarjafar pinjar
957418
957418
add a comment |
add a comment |
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;
add a comment |
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;
add a comment |
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;
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;
edited May 28 at 15:26
answered May 28 at 14:29
Khoa TruongDinhKhoa TruongDinh
22.5k64491
22.5k64491
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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