{"id":37,"date":"2018-03-22T11:10:55","date_gmt":"2018-03-22T11:10:55","guid":{"rendered":"http:\/\/codeinnovers.com\/blog\/?p=37"},"modified":"2018-03-22T11:15:31","modified_gmt":"2018-03-22T11:15:31","slug":"creating-a-hello-world-module-in-magento-2","status":"publish","type":"post","link":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/","title":{"rendered":"how to create a hello world module in magento-2"},"content":{"rendered":"<p>In Today&#8217;s tutorial we will see how to create a hello world module in Magento-2. We will print hello world on the screen.<\/p>\n<p>The objective of today&#8217;s tutorial is to understand the module structure of Magento-2 and we will show a hello world text on screen.<\/p>\n<p>First of all we will have to follow these steps:<\/p>\n<ol>\n<li>\n<h3>Disable Magento Cache:<\/h3>\n<p>Magento 2 has implemented cache in very awesome way which results into quick page load and fast speed . Whenever we will make any change in code , it will not be reflected on site because Magento&#8217;s Caching system will be loading it from cache so we will have to flush the cache every time which results into wasting of time. To save our time we will disable the cache. To disable cache go to Admin \u2192 System \u2192 Cache Management \u2192 select all cache types and disable them.<\/li>\n<li>\n<h3>Enable Developer Mode:<\/h3>\n<p>By default Magento runs in default mode , and we need to make it run into developer mode. Why developer mode ? because enabling developer mode will show all the errors . Run below command to enable developer mode.<\/p>\n<pre class=\"ish\"><code class=\"language-php\">php bin<span class=\"sy0\">\/<\/span>magento deploy<span class=\"sy0\">:<\/span>mode<span class=\"sy0\">:<\/span>set developer<\/code><\/pre>\n<p>If you are using xampp on your localthen run this command\u00a0 <code class=\"language-php\"><\/code><\/p>\n<p><code class=\"language-php\">\/opt\/lampp\/bin\/php bin<span class=\"sy0\">\/<\/span>magento deploy<span class=\"sy0\">:<\/span>mode<span class=\"sy0\">:<\/span>set developer<\/code><\/li>\n<\/ol>\n<h2>Magento-2 Module Structure<\/h2>\n<p>For those who are familiar with Magento-1 , module structure of Magento-2 is bit different. In Magento 1 our code used to split in various folders and creating an install-able package was a tough job , but in Magento-2 code of one module resides inside one folder and can be easily used to create install-able package.<\/p>\n<h4><strong>Directory Structure of Magento Module:<\/strong><\/h4>\n<p>app\/code\/&lt;namespace&gt;\/&lt;module_name&gt;<\/p>\n<p>&lt;namespace&gt; which may also be called as vendor_name is the name of folder which contains module. A namespace may have any number of modules. For this tutorial we will be using <strong>Mega<\/strong> as namespace or say vendor_name<\/p>\n<p>&lt;module_name&gt;\u00a0 is the name of module which we are building. Always chose a name for module which reflects the module functionality. It is considered as best practice. We will be using <strong>HelloWorld<\/strong> as module name<\/p>\n<p>So detailed directory structure will be:<\/p>\n<p><strong>Mega\/HelloWorld\/<\/strong><\/p>\n<p><strong>Block : <\/strong>This folder contains the block files<\/p>\n<p><strong>Controller: <\/strong>This folder contains the Controller Files<\/p>\n<p><strong>Helper : <\/strong>This folder contains the helper Files<\/p>\n<p><strong>Model: <\/strong>This folder contains the Model Files<\/p>\n<p><strong>Observer:\u00a0 <\/strong>This folder contains the Observer Files which are used to hook any event. In Magento 2 we use <strong>di.xml<\/strong> for hooking events. Event System is not in the scope of this post. We will discuss event system in near future posts.<\/p>\n<p><strong>Setup:<\/strong>\u00a0This setup folder is equivalent to Magento-1&#8217;s sql folder. This folder holds the installData and InstallSchema file ffor manipulating the database. With the help of these files we can create , alter table and other operations at Database level<\/p>\n<p><strong>etc : <\/strong>This folder contains the configuration for front-end as well as admin area.<\/p>\n<p><strong>view: <\/strong>This folder has 2 sub folders. adminhtml and frontend. These folders contains the layout , template files as well as javascript and css files.<\/p>\n<p><strong>Creating Hello World Module in Magento-2<\/strong><\/p>\n<p>We will be creating these files for creating a hello world module. For fresh Magento-2 installation you notice that there is no <strong>code<\/strong> folder , you may create it manually.<\/p>\n<ol>\n<li>\u00a0app\/code\/Mega\/HelloWorld\/etc\/module.xml file<\/li>\n<li>\u00a0app\/code\/Mega\/HelloWorld\/registration.php<\/li>\n<li>app\/code\/Mega\/HelloWorld\/etc\/frontend\/routes.xml<\/li>\n<li>app\/code\/Mega\/HelloWorld\/Controller\/Index\/Index.php<\/li>\n<li>app\/code\/Mega\/HelloWorld\/Block\/Hello.php<\/li>\n<li>app\/code\/Mega\/HelloWorld\/view\/frontend\/layout\/helloworld_index_index.xml<\/li>\n<li>app\/code\/Mega\/HelloWorld\/view\/frontend\/templates\/hello.phtml<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4>Creating app\/code\/Mega\/HelloWorld\/module.xml<\/h4>\n<pre class=\"ish\"><code class=\"language-xml\"><span class=\"sc3\"><span class=\"re1\">&lt;?xml<\/span> <span class=\"re0\">version<\/span>=<span class=\"st0\">\"1.0\"<\/span><span class=\"re2\">?&gt;<\/span><\/span>\r\n<span class=\"sc3\"><span class=\"re1\">&lt;config<\/span> <span class=\"re0\">xmlns:xsi<\/span>=<span class=\"st0\">\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"<\/span> <span class=\"re0\">xsi:noNamespaceSchemaLocation<\/span>=<span class=\"st0\">\"urn:magento:framework:Module\/etc\/module.xsd\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;module<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">\"Mega_HelloWorld\"<\/span> <span class=\"re0\">setup_version<\/span>=<span class=\"st0\">\"1.0.0\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;\/module<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n<span class=\"sc3\"><span class=\"re1\">&lt;\/config<span class=\"re2\">&gt;<\/span><\/span><\/span><\/code><\/pre>\n<p>In above code , setup_version is the setup version of the module. This version is checked when we want to create a table or we want to do some database level operations.<\/p>\n<h4><strong>Registering the module<\/strong><\/h4>\n<p>To register a module we will create a <strong>registration.php<\/strong> file with below contents:<\/p>\n<pre class=\"ish\"><code class=\"language-php\"><span class=\"kw2\">&lt;?php<\/span>\r\n\\Magento\\Framework\\Component\\ComponentRegistrar<span class=\"sy0\">::<\/span><span class=\"me2\">register<\/span><span class=\"br0\">(<\/span>\r\n    \\Magento\\Framework\\Component\\ComponentRegistrar<span class=\"sy0\">::<\/span><span class=\"me2\">MODULE<\/span><span class=\"sy0\">,<\/span>\r\n    <span class=\"st_h\">'Mega_HelloWorld'<\/span><span class=\"sy0\">,<\/span>\r\n    __DIR__\r\n<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><\/code><\/pre>\n<p>After performing above steps our module is created and registered in Magento. Now we will confirm that our module is registered. By default when we create a module , it is disabled. So we have to enabled the module too.<\/p>\n<p>Open terminal and change directory to your magento root and run this command<\/p>\n<p><code><span class=\"nx\">php<\/span> <span class=\"nx\">bin<\/span><span class=\"o\">\/<\/span><span class=\"nx\">magento<\/span> <span class=\"nx\">module<\/span><span class=\"o\">:<\/span><span class=\"nx\">status<\/span><\/code><\/p>\n<p>This command will show some output and last of the output will look like this<\/p>\n<p><strong>List of disabled modules: Mega_HelloWorld<\/strong><\/p>\n<p>now we will enable the module by running this command<\/p>\n<pre class=\"highlight\"><code><span class=\"nx\">php<\/span> <span class=\"nx\">bin<\/span><span class=\"o\">\/<\/span><span class=\"nx\">magento<\/span> <span class=\"nx\">module<\/span><span class=\"o\">:<\/span><span class=\"nx\">enable<\/span> <span class=\"nx\">Mega_HelloWorld<\/span><\/code><code>\r\n<\/code><\/pre>\n<p>Now if we check file app\/etc\/config.php we will find this<\/p>\n<pre class=\"highlight\"><code><span class=\"s1\">'Mega_HelloWorld'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"mi\">1<\/span><\/code> This confirms that our module is now enabled and registered. After this we will define a route for our module. In this we will define a frontname of the module. In Magento url is comprises of module frontname , controller name and action name. Now we will register frontname for our module. Create <strong>routes.xml<\/strong> in <strong>app\/code\/local\/Mega\/HelloWorld\/etc\/frontend\/routes.xml<\/strong><\/pre>\n<pre class=\"ish\"><code class=\"language-xml\"><span class=\"sc3\"><span class=\"re1\">&lt;?xml<\/span> <span class=\"re0\">version<\/span>=<span class=\"st0\">\"1.0\"<\/span><span class=\"re2\">?&gt;<\/span><\/span>\r\n<span class=\"sc3\"><span class=\"re1\">&lt;config<\/span> <span class=\"re0\">xmlns:xsi<\/span>=<span class=\"st0\">\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"<\/span> <span class=\"re0\">xsi:noNamespaceSchemaLocation<\/span>=<span class=\"st0\">\"urn:magento:framework:App\/etc\/routes.xsd\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;router<\/span> <span class=\"re0\">id<\/span>=<span class=\"st0\">\"standard\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n        <span class=\"sc3\"><span class=\"re1\">&lt;route<\/span> <span class=\"re0\">id<\/span>=<span class=\"st0\">\"helloworld\"<\/span> <span class=\"re0\">frontName<\/span>=<span class=\"st0\">\"helloworld\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n            <span class=\"sc3\"><span class=\"re1\">&lt;module<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">\"Mega_HelloWorld\"<\/span> <span class=\"re2\">\/&gt;<\/span><\/span>\r\n        <span class=\"sc3\"><span class=\"re1\">&lt;\/route<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;\/router<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n<span class=\"sc3\"><span class=\"re1\">&lt;\/config<span class=\"re2\">&gt;<\/span><\/span><\/span><\/code><\/pre>\n<pre class=\"highlight\">Now we will create index controller and index action\r\ncreate a folder inside Controller folder . Name the folder Index and create a file index.php in it\r\n\r\nAdd below code in file\r\n\r\n<\/pre>\n<pre class=\"ish\"><code class=\"language-php\"><span class=\"kw2\">&lt;?php<\/span>\r\n<span class=\"kw2\">namespace<\/span> Mega\\HelloWorld\\Controller\\Index<span class=\"sy0\">;<\/span>\r\n<span class=\"kw2\">use<\/span> Magento\\Framework\\App\\Action\\Context<span class=\"sy0\">;<\/span>\r\n<span class=\"kw2\">class<\/span> Index <span class=\"kw2\">extends<\/span> \\Magento\\Framework\\App\\Action\\Action\r\n<span class=\"br0\">{<\/span>\r\n    <span class=\"kw2\">protected<\/span> <span class=\"re0\">$_resultPageFactory<\/span><span class=\"sy0\">;<\/span>\r\n\u00a0\r\n    <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> __construct<span class=\"br0\">(<\/span>Context <span class=\"re0\">$context<\/span><span class=\"sy0\">,<\/span> \\Magento\\Framework\\View\\Result\\PageFactory <span class=\"re0\">$resultPageFactory<\/span><span class=\"br0\">)<\/span>\r\n    <span class=\"br0\">{<\/span>\r\n        <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span>_resultPageFactory <span class=\"sy0\">=<\/span> <span class=\"re0\">$resultPageFactory<\/span><span class=\"sy0\">;<\/span>\r\n        parent<span class=\"sy0\">::<\/span>__construct<span class=\"br0\">(<\/span><span class=\"re0\">$context<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\r\n    <span class=\"br0\">}<\/span>\r\n\u00a0\r\n    <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> execute<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\r\n    <span class=\"br0\">{<\/span>\r\n        <span class=\"re0\">$resultPage<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span>_resultPageFactory<span class=\"sy0\">-&gt;<\/span><span class=\"me1\">create<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\r\n        <span class=\"kw1\">return<\/span> <span class=\"re0\">$resultPage<\/span><span class=\"sy0\">;<\/span>\r\n    <span class=\"br0\">}<\/span>\r\n<span class=\"br0\">}<\/span><\/code> Now Let's create a block file that will provide the hello world text to our template file that will print the text screen. Create a file Hello.php in Block folder in module and add the below contents<\/pre>\n<pre class=\"ish\"><code class=\"language-php\"><span class=\"kw2\">&lt;?php<\/span>\r\n<span class=\"kw2\">namespace<\/span> Mega\\HelloWorld\\Block<span class=\"sy0\">;<\/span>\r\n\u00a0\r\n<span class=\"kw2\">class<\/span> Hello <span class=\"kw2\">extends<\/span> \\Magento\\Framework\\View\\Element\\Template\r\n<span class=\"br0\">{<\/span>\r\n    <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> getTextToPrint<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\r\n    <span class=\"br0\">{<\/span>\r\n        <span class=\"kw1\">return<\/span> <span class=\"st_h\">'Hello world!'<\/span><span class=\"sy0\">;<\/span>\r\n    <span class=\"br0\">}<\/span>\r\n<span class=\"br0\">}\r\n\r\n<\/span><\/code>Now we will create a layout file to include our block and template for our module for url of index controller and index action. In Magento-2 this is done a bit differently than magento-1. in Magento-2 for every controller action we create a separate layout file. we will create file <strong>hellowold_index_index.xml<\/strong> in <strong><em>view\/frontend\/layout<\/em><\/strong> folder and add the below contents<\/pre>\n<pre class=\"ish\"><code class=\"language-xml\"><span class=\"sc3\"><span class=\"re1\">&lt;page<\/span> <span class=\"re0\">xmlns:xsi<\/span>=<span class=\"st0\">\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"<\/span> <span class=\"re0\">xsi:noNamespaceSchemaLocation<\/span>=<span class=\"st0\">\"..\/..\/..\/..\/..\/..\/..\/lib\/internal\/Magento\/Framework\/View\/Layout\/etc\/page_configuration.xsd\"<\/span> <span class=\"re0\">layout<\/span>=<span class=\"st0\">\"1column\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;body<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n        <span class=\"sc3\"><span class=\"re1\">&lt;referenceContainer<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">\"content\"<\/span><span class=\"re2\">&gt;<\/span><\/span>\r\n            <span class=\"sc3\"><span class=\"re1\">&lt;block<\/span> <span class=\"re0\">class<\/span>=<span class=\"st0\">\"Mega\\HelloWorld\\Block\\Hello\"<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">\"megahelloworld\"<\/span> <span class=\"re0\">template<\/span>=<span class=\"st0\">\"hello.phtml\"<\/span> <span class=\"re2\">\/&gt;<\/span><\/span>\r\n        <span class=\"sc3\"><span class=\"re1\">&lt;\/referenceContainer<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n    <span class=\"sc3\"><span class=\"re1\">&lt;\/body<span class=\"re2\">&gt;<\/span><\/span><\/span>\r\n<span class=\"sc3\"><span class=\"re1\">&lt;\/page<span class=\"re2\">&gt;\r\n\r\n<\/span><\/span><\/span><\/code>Now we will create a template file <strong>hello.phtml<\/strong> in <strong><em>view\/frontend\/templates<\/em><\/strong> folder. We will add the below content<\/pre>\n<pre class=\"ish\"><code class=\"language-html5\"><span class=\"sc2\">&lt;p&gt;&lt;?php echo $this-&gt;<\/span><code class=\"language-php\">getTextToPrint<\/code>(); ?&gt;<span class=\"sc2\">&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">p<\/span>&gt;\r\n\r\n<\/span><\/code><\/pre>\n<p><span><br \/>\nWe are done with all sort of codes and now if we open the below url <url_to_magento>\/helloworld\/index\/index<br \/>\nwe will see a hello world text printed on screen. That&#8217;s all for today&#8217;s post. If you face any issue or you have any doubt feel free to post it in comments and we will help you out. If you need any service or you are looking for customization in your magento store feel free to drop us a line using the form on  http:\/\/www.codeinnovers.com\/contact-us<br \/>\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Today&#8217;s tutorial we will see how to create a hello world module in Magento-2. We will print hello world on the screen. The objective of today&#8217;s tutorial is to understand the module structure of Magento-2 and we will show a hello world text on screen. First of all we will have to follow these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":41,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[10,12,13,9],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v19.5 (Yoast SEO v19.10) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>how to create a hello world module in magento-2 - CodeInnovers<\/title>\n<meta name=\"description\" content=\"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"how to create a hello world module in magento-2\" \/>\n<meta property=\"og:description\" content=\"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeInnovers\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-22T11:10:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-22T11:15:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeinnovers.com\/blog\/wp-content\/uploads\/2018\/03\/hello.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"200\" \/>\n\t<meta property=\"og:image:height\" content=\"250\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sam Parker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sam Parker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/\",\"url\":\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/\",\"name\":\"how to create a hello world module in magento-2 - CodeInnovers\",\"isPartOf\":{\"@id\":\"https:\/\/codeinnovers.com\/blog\/#website\"},\"datePublished\":\"2018-03-22T11:10:55+00:00\",\"dateModified\":\"2018-03-22T11:15:31+00:00\",\"author\":{\"@id\":\"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/bbe49f6f2028b54a87fabd0b6dd3a3f8\"},\"description\":\"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2\",\"breadcrumb\":{\"@id\":\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codeinnovers.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"how to create a hello world module in magento-2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codeinnovers.com\/blog\/#website\",\"url\":\"https:\/\/codeinnovers.com\/blog\/\",\"name\":\"CodeInnovers\",\"description\":\"Developing the impossible\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codeinnovers.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/bbe49f6f2028b54a87fabd0b6dd3a3f8\",\"name\":\"Sam Parker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/10f48f28ca8c9e285071c94e88696979?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/10f48f28ca8c9e285071c94e88696979?s=96&d=mm&r=g\",\"caption\":\"Sam Parker\"},\"url\":\"https:\/\/codeinnovers.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"how to create a hello world module in magento-2 - CodeInnovers","description":"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"how to create a hello world module in magento-2","og_description":"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2","og_url":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/","og_site_name":"CodeInnovers","article_published_time":"2018-03-22T11:10:55+00:00","article_modified_time":"2018-03-22T11:15:31+00:00","og_image":[{"width":200,"height":250,"url":"https:\/\/codeinnovers.com\/blog\/wp-content\/uploads\/2018\/03\/hello.jpg","type":"image\/jpeg"}],"author":"Sam Parker","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sam Parker","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/","url":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/","name":"how to create a hello world module in magento-2 - CodeInnovers","isPartOf":{"@id":"https:\/\/codeinnovers.com\/blog\/#website"},"datePublished":"2018-03-22T11:10:55+00:00","dateModified":"2018-03-22T11:15:31+00:00","author":{"@id":"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/bbe49f6f2028b54a87fabd0b6dd3a3f8"},"description":"In this post we will create a hello world module in magento 2 to understand the flow and module structure of magento 2","breadcrumb":{"@id":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codeinnovers.com\/blog\/creating-a-hello-world-module-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeinnovers.com\/blog\/"},{"@type":"ListItem","position":2,"name":"how to create a hello world module in magento-2"}]},{"@type":"WebSite","@id":"https:\/\/codeinnovers.com\/blog\/#website","url":"https:\/\/codeinnovers.com\/blog\/","name":"CodeInnovers","description":"Developing the impossible","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeinnovers.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/bbe49f6f2028b54a87fabd0b6dd3a3f8","name":"Sam Parker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeinnovers.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/10f48f28ca8c9e285071c94e88696979?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/10f48f28ca8c9e285071c94e88696979?s=96&d=mm&r=g","caption":"Sam Parker"},"url":"https:\/\/codeinnovers.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/posts\/37"}],"collection":[{"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":12,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":50,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions\/50"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/media\/41"}],"wp:attachment":[{"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinnovers.com\/blog\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}