How to create a composer package for a Nova Resource - php

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?

Related

How should I work in a Laravel project under git, and at the same time in a Laravel component in a component/ folder in the same laravel project

I have a main project using laravel framework under git.
Now, I have to code a component that must have his own git repository, but I need to code it into /component/mycomponent in my Laravel project.
My issue is that if I specify a new origin for my component, it will also set it for main project. How should I do ?
*Edit: A little more "PHP" way as using git submodules, which kerbh0lz suggested.
Create a new repository for the component and require it by composer in the main project.
If you really need a physical class / file in /component/mycomponent just put a class in there which extends from the one in vendor.

How to reinstall user auth modules in laravel

I inherited a Laravel project in which there doesn't appear to be a app/User.php file or any migration scripts related to the creation of user tables for the database. This project was initially used to create a simple REST API end point to write records to a single table without authentication.
Is there a simple command I can run to re-introduce the Laravel user components? My goal is to install Laravel Passport with OAuth2 support, but it seems to depend on the existence of user modules.
you can follow the instruction in the docs: https://laravel.com/docs/7.x/authentication#introduction
Want to get started fast? Install the laravel/ui Composer package and
run php artisan ui vue --auth in a fresh Laravel application. After
migrating your database, navigate your browser to
http://your-app.test/register or any other URL that is assigned to
your application. These commands will take care of scaffolding your
entire authentication system!

Laravel Mix hot reloading inside the package

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).

Yii2 Framework - Custom Installation Template

When I access to Yiisoft account on Github:
https://github.com/yiisoft
I see 3 pinned repos: Yii2, Yii2-app-basic and Yii2-app-advanced.
I know When I run the command:
composer create-project [template] [project-name]
I can create a project using one of installation templates. Also I know on the composer.json on this templates is set yii2 framework and yii2 bootstrap as dependencies, so they get downloaded.
What about if I want to create my own installation template, is there a guide how to do it?. I know it would not be that productive but just wondering out of curiosity.
UPDATE
I have noticed that just a couple hours ago this page was published:http://www.yiiframework.com/doc-2.0/guide-tutorial-start-from-scratch.html
but still it is based on the basic installation template, not a totally custom one.

Laravel: Working with a 3rd party bundle

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.

Categories