0

In order to add a new admin page, I follow this tutorial :

in the routes.xml, If I use as it is said the module name for id and frontname, I get an error when I try to access magento2 backend

routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="modulename" frontName="modulename">
            <module name="Mine_Modulename" />
        </route>
    </router>
</config>

error :

a:4:{i:0;s:227:"Warning: file_put_contents(/var/www/html/magento/var/cache//mage-tags/mage---365_STORE_RELATIONS): failed to open stream: Permission denied in /var/www/html/magento/vendor/colinmollenhour/cache-backend-file/File.php on line 663";i:1;s:4199:"#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'file_put_conten...', '/var/www/html/m...', 663, Array)
#1 /var/www/html/magento/vendor/colinmollenhour/cache-backend-file/File.php(663): file_put_contents('/var/www/html/m...', '365_RESOLVED_ST...', 10)
#2 /var/www/html/magento/vendor/colinmollenhour/cache-backend-file/File.php(179): Cm_Cache_Backend_File->_updateIdsTags(Array, Array, 'merge')
#3 /var/www/html/magento/vendor/magento/zendframework1/library/Zend/Cache/Core.php(390): Cm_Cache_Backend_File->save('a:2:{i:0;a:1:{i...', '365_RESOLVED_ST...', Array, NULL)
#4 /var/www/html/magento/vendor/magento/framework/Cache/Core.php(74): Zend_Cache_Core->save('a:2:{i:0;a:1:{i...', 'RESOLVED_STORES...', Array, NULL, 8)
#5 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(47): Magento\Framework\Cache\Core->save('a:2:{i:0;a:1:{i...', 'RESOLVED_STORES...', Array, NULL)
#6 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Adapter\Zend->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#7 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/TagScope.php(49): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#8 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Decorator\TagScope->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#9 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#10 /var/www/html/magento/vendor/magento/framework/App/Cache/Type/AccessProxy.php(85): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#11 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\App\Cache\Type\AccessProxy->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#12 /var/www/html/magento/vendor/magento/framework/Cache/Frontend/Decorator/TagScope.php(49): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array, NULL)
#13 /var/www/html/magento/vendor/magento/module-store/Model/StoreResolver.php(123): Magento\Framework\Cache\Frontend\Decorator\TagScope->save('a:2:{i:0;a:1:{i...', 'resolved_stores...', Array)
#14 /var/www/html/magento/vendor/magento/module-store/Model/StoreResolver.php(85): Magento\Store\Model\StoreResolver->getStoresData()
#15 /var/www/html/magento/vendor/magento/module-store/Model/StoreManager.php(154): Magento\Store\Model\StoreResolver->getCurrentStoreId()
#16 /var/www/html/magento/var/generation/Magento/Store/Model/StoreManagerInterface/Proxy.php(119): Magento\Store\Model\StoreManager->getStore(NULL)
#17 /var/www/html/magento/vendor/magento/module-store/Model/Resolver/Store.php(29): Magento\Store\Model\StoreManagerInterface\Proxy->getStore(NULL)
#18 /var/www/html/magento/vendor/magento/framework/App/Config/ScopeCodeResolver.php(49): Magento\Store\Model\Resolver\Store->getScope(NULL)
#19 /var/www/html/magento/vendor/magento/framework/App/Config.php(79): Magento\Framework\App\Config\ScopeCodeResolver->resolve('stores', NULL)
#20 /var/www/html/magento/vendor/magento/module-backend/App/Area/FrontNameResolver.php(96): Magento\Framework\App\Config->getValue('admin/url/use_c...', 'store')
#21 /var/www/html/magento/vendor/magento/module-backend/App/Area/FrontNameResolver.php(79): Magento\Backend\App\Area\FrontNameResolver->isHostBackend()
#22 /var/www/html/magento/vendor/magento/framework/App/AreaList.php(73): Magento\Backend\App\Area\FrontNameResolver->getFrontName(true)
#23 /var/www/html/magento/vendor/magento/framework/App/Http.php(130): Magento\Framework\App\AreaList->getCodeByFrontName('admin_toto')
#24 /var/www/html/magento/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#25 /var/www/html/magento/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#26 {main}";s:3:"url";s:23:"/magento/admin_toto";s:11:"script_name";s:18:"/magento/index.php";}

Any idea?

Thank you for your help

  • 1
    make sure you have write permissions on the var folder. – Marius May 4 '17 at 8:30
1

Please give write permissions to var folder. You can run below command from Magento 2 root directory to give permissions.

chmod 775 -R var/
| improve this answer | |
  • It is not safe to give write permissions for others to any Magento 2 folder. 775 permissions are enough, or 755 if it's a one-user ownership. – Thomas Domingues May 4 '17 at 9:17
  • I checked but all files are 777 (local dev sverver) – Alexglvr May 4 '17 at 9:21
0

You have to give <magento_root_folder>/var write permissions for your Web server user / group. For more information, please follow Magento 2 DevDocs guide for setting permissions in development and production.

| improve this answer | |
  • if I change the id frontname of routes with controller nameinstead of module name, no more error (except I can not reach the created page, but this is another problem) ie not dur to permission – Alexglvr May 4 '17 at 9:27
  • You can set your route ID as the module name, and then set the frontend name as whatever you want. Suppposing this router : <route id="vendor_module" frontName="tototest"><module name="Vendor_Module" /></route>; If you created your controller in app/code/Vendor/Module/Controller/Adminhtml/Index/Index, then you can acces your newly created page with this URL : http<s>://hostname.tld/magento/<admin_name>/tototest – Thomas Domingues May 4 '17 at 9:33
  • Else, try to clean cache (if cache is enabled) by launching this command from your Magento root folder : php bin/magento cache:clean And refresh the page. – Thomas Domingues May 4 '17 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.