How To Create Package ?
-
-
Can you attach for this url also - http://localhost:7777/bagisto/public/hello-world
Thanks
-
-
-
open HelloWorldServiceProvider.php and change your boot method to this
/** * Bootstrap services. * * @return void */ public function boot() { $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); $this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'helloworld'); $this->loadViewsFrom(__DIR__.'/../Resources/views', 'helloworld'); }
Inside your package open src/Http/routes.php and add this at the end of the file
replace yourpackage and viewname with yours.Route::view('/hello-world', 'yourpackage::viewname');
go the the root folder of bagisto and run the following commands
composer dump-autoload php artisan route:cache
Once that is done open your browser and go to http://localhost:7777/bagisto/public/hello-world and verify if it works.
-
it didnt work can i upload my project here to check for errors ?
-
-
Thanks. https://we.tl/t-EAIrf1pmyb
-
Hi,
We have solved your errors. Kindly find the attach file.
What are problems in your package is -$this->mergeConfigFrom( dirname(__DIR__) . '/Config/menu.php', 'menu.admin' );
you are adding your package's menu.php file with admin but your package does not consist menu.php file (Config/menu.php).
- You don't use Event in your service provider but you are using it in your boot method.
Event::listen('bagisto.admin.layout.head', function($viewRenderEventManager) { $viewRenderEventManager->addTemplate('helloworld::helloworld.layouts.style'); });
3 . Lang file will be called like this -
{{ __('helloworld::app.hello-world.name') }} instead of {{ __(‘helloworld::app.hello-world.name’) }}
Thanks
[0_1565001753477_ACME.zip](Uploading 100%)[0_1565002008993_ACME.zip](Uploading 100%)
-
@rahul said in How To Create Package ?:
0_1565002008993_ACME
can you please reupload the attach file
-
-
-
Hi
I sent it.
Thanks
-
i didn't recieve the email.
-
@rahul it might be a good idea to write here the cause of the problem so people can learn from it?
-
- HelloWorldServiceProvider.php file
<?php namespace ACME\HelloWorld\Providers; use Event; use Illuminate\Support\ServiceProvider; /** * HelloWorld service provider * * @author Jane Doe <[email protected]> * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class HelloWorldServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot() { $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); $this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'helloworld'); $this->loadViewsFrom(__DIR__.'/../Resources/views', 'helloworld'); Event::listen('bagisto.admin.layout.head', function($viewRenderEventManager) { $viewRenderEventManager->addTemplate('helloworld::helloworld.layouts.style'); }); $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); } /** * Register services. * * @return void */ public function register() { // $this->mergeConfigFrom( // dirname(__DIR__) . '/Config/menu.php', 'menu.admin' // ); } }
- helloworld.blade.php file -
{{ __('helloworld::app.hello-world.name') }} {{-- @extends('admin::layouts.master') --}}
- routes.php file
<?php Route::view('/hello-world', 'helloworld::helloworld.helloworld');
- app.php file for en.
<?php return [ 'hello-world' => [ 'name' => 'My Name is jane doe', ] ];
Thanks
-
i did these changes but i still can't access that url i think there is an error somewhere else here is my whole project: https://we.tl/t-ZxQA9ugf6s
-
I am unable to open your file but i think you are missing these things -
- Add this to app.php file (Inside Config folder ).
ACME\HelloWorld\Providers\HelloWorldServiceProvider::class
- Add this to composer.json under 'psr-4'.
"ACME\\HelloWorld\\": "packages/ACME/HelloWorld/src"
Run 'php artisan config:clear', 'composer dump-autoload' & 'php artisan vendor:publish'.
and please see attached image for where your package should be -
Thanks
-
This post is deleted! -
thanks a lot i did all those edits in my project then php artisan config:clear , composer dump-autoload , php artisan route:cache and it worked.The problem now is when i go to hello-world i get this displayed "helloworld::app.hello-world.name"