I've been trying to create an admin panel for Laravel (I know, there is a Laravel Nova now for 99$ for a single site) and all I've been doing is trying to build all of this functionality on top of laravel/laravel package.
What I've seen with Nova, is that it is a separate package, which is seamlessly integrates with Laravel by simply dragging and dropping the folder with Nova to the root directory of the Laravel application.
Even though, I have an idea (and a little bit of experience) on how to replicate (and maybe even enhance Nova functionality), I've no idea on how to make HMR working with the package.
Let's say my package name is Niva (just an example), with the folder named niva placed inside the Laravel folder. The webpack.mix.js is the same as in the Laravel Horizon package.
So far, I've no problems with accessing routes defined in the package, I'm able to load views from the package by accessing specified route, even authentication works just fine. However, I have to manually compile the package first, then publish the assets, and only then I can view the changes I've made to the source code.
Example package base routes:
Web: _http://localhost/niva (Only need for HMR to be present here)
Api: _http://localhost/api/niva
Example package base directories and files:
Root: /var/www/localhost/niva
Public: /var/www/localhost/niva/public
Resources: /var/www/localhost/niva/resources
Webpack: /var/www/localhost/niva/webpack.mix.js
What I'm asking about is: is it possible to enable HMR for the package, and how it should be done?
P.S. I've been thinking of symlinking the public directory from the package to the public vendor/niva folder, but still no result (I'm pretty sure I'm missing something here).
Related
I am building a Nova Page Builder for our company but am new to creating composer packages. Here is what I have as far as files:
Models / Page.php (model)
Nova / Pages.php (handles fields for the model)
Migration file to build "pages" table
Requires other composer packages for things like nova-tabs, nova-menu, nova-flexible-fields.
I have this all working in a Nova project but we are wanting to turn this into a composer package that can be installed in other projects. I can think of 3 ways to do this.
Create a custom Nova tool (I don't want to have to do all of this unless necessary, creating custom Vue components for default Nova behavior seems like overkill)
Publish the above files to the app/database directories using Composer and run the migrations
Somehow link the vendor/ files for this package to the local app instance? I'm not even sure if this doable.
It would be nice if we could just include a service provider and it would all work, is that possible without creating a custom Nova tool?
Any advice on which route to go down?
I am developing a Laravel Package which installs a list of dependencies.
The dependencies have their own configuration files to be published after installation.
What we need is to auto (to avoid doing it manually) modify the config files of these dependencies by our package before/after publishing them and placing them in app/config.
I found some solutions like using mergeConfigFrom() in register method of Package's service provider. But it doesn't modify file content itself, just loads the merged config.
We need to modify config file's content by the package that we developing so that we don't need to change config file manually after package installation.
For example, we install Laravel Horizon as a dependency the our package. Horizon publishes a config file called horizon.php in app/config. We need to auto modify some values for app/config/horizon.php before or after publishing that config file.
Any help will be much appreciated.
Thanks :)
This is currently not possible. Look at Illuminate\Foundation\Console\VendorPublishCommand in the laravel framework source code.
Best way to go is to completely replace horizon.php config in your package by publishing it on the same file.
Alternativly you can write a custom command to inject this data in the horizon.php
You could make a PR in laravel framework for you to allow this. and hope for the best they accept your PR.
I have a working Laravel 5.1 site. I have multiple packages that are in my vendor directory as well as the workbench directory. For the most part, when I edit one of the packages, I instantly see my changes. However, I have one package that Laravel is looking at the vendor directory only, so no matter what changes I make to controllers, models, or views for this package in the workbench directory, nothing changes. If I make any change in the vendor directory, that change is immediately seen. When I first came in this morning, I was able to edit the controller and see my change, but I was having issues with Laravel saying that it could not find the view. I ran a php artisan optimize and that fixed the issue of the view not being found, but now this Laravel only looks for code for this package in the vendor directory, not workbench.
Does anyone have a suggestion of what I can try to get Laravel to acknowledge the package in the workbench directory as apposed to the Vendor directory?
I did check permissions to see if the server just didn't have access to this directory, but that is not the case, it has the appropriate permissions.
This is a basic best practice question.
I started my first project using the Laravel framework. I just recently added the L4withSentry bundle to my laravel project. I followed the setup steps and everything is up and running fine, but I noticed that all of the code that's running for the site is running from the vendor folder of my project even though I published all of the views and assets.
Should I leave all of the code in the vendor folder and customize it there? I'm under the understanding that if I update composer and any of the vendor files need to be updated I'll lose all of my code. Should I move the controllers into my app folder?
packages should stay in the vendor folder. the sentry package makes it actually easy to customize or set your own model outside of sentry, so you don't have to fiddle with vendor packages.
if you really have to change some behaviour in a vendor package, you'd create a new class extending that vendor package's class.
Although I've used TCPDF before I am using it with composer for the first time through Laravel 4.
I am fighting the urge to edit any package files directly but their are config settings/ constants in TCPDF that I would like to be able to change.
I do know vendor config files can be published using:
php artisan config:publish {package}
But I don't think the TCPDF package I am using has this feature. The package is:
https://packagist.org/packages/tecnick.com/tcpdf
Don't really know much more about the package either as the git page seems to be down.
So to my questions:
Is publishing the config possible?
If not what would be the best way to to apply custom settings without touching the vendor?
Finally if the above will not really work is their a better Laravel 4 based solution that allows for HTML to PDF generation?
Thanks for reading
I'm not able to view the source of the package but the publishing of configuration will only work for Laravel specific packages that have setup and registered the package correctly. For other packages that require configuration they should provide some means for extending the configuration to avoid the possibility of adjusted config being overwritten by a composer update.