Laravel 5 package development clarity - laravel-5

Ive been reading a few articles on the net about package development but cant quite wrap my head around the basic setup. Ive written jQuery plugins with releases and published to Bower in the passed so maybe im just not understanding the difference with Laravel.
With jQuery plugin dev I would just exclude my dev required dependancies through bower.json to prevent a person pulling in my dependancies. It seems that with Laravel u create an un-tracked Laravel framework folder and put your package into the vendor folder and track only that with Git? So basically the Laravel project sitting outside of my vendor package is just some files on my PC? Surely I would want to track which version of Laravel the package was developed on?
OR should I create a "base" Laravel repository and create another repository inside the vendor folder so make sure I know which Laravel the package was built on?
Documentation and tutorials are very vague...

Your question looks a little bit confuse. I develop packages for Laravel and the following is a regular way:
Laravel manage its dependencias via composer, take a look into composer.json to get a clue how similiar is with bower.
In order to get yout package compatible with laravel's core you need to implement some interfaces in your package. This package also can manage dependencies via composer.
A package can be created as a repository in different version controls, like Github, BitBucket, Packagist, Cartalyst, private packages repositories, etc. By default laravel pull packages from Packagist, but into composer.json file you can specify another reposository as needed.
When you trigger composer update (this is an equivalent as bower update), this dependencies manager will pull all the packages and download them automatically in vendor/ directory.
How to code your package while testing with laravel? some people do the following, including me:
Install a laravel instance just for package development purpose.
Create a new project (your package project) inside of vendor/project-name following lavavel's package requirements.
Keep working your package from this project location. By this way the changes are reflecting instantly in laravel installation.
Don't forget to commit and push

Related

Do I have to install gin framework in every new folder I create in visual Studio code for Golang programmes?

I have already installed gin framework in a different folder on my desktop named Gingo. I am learning how to build a web RESTful API through the Gin framework,
by starting the implementation of the backend code that is needed to support our Go Music.
But I have created another folder on my desktop for this Go Music named backend, so do I have to install gin framework in this folder as well?
The project can be found at https://github.com/gin-gonic/
gin.
i think you must install in every project, in my opinion because framework on golang just thrid party labrary. but if you want to install on your system you can try this. maybe its can be new journery on your programming
The way you use external libraries and frameworks in Go is by using Go modules. Initialise your project by running go mod init name-of-project in the backend folder (or whatever the root folder is for your Go code).
Now, if you want to add gin to your project, you can run go get github.com/gin-gonic/gin, which adds gin to the dependencies of your project (you can see all dependencies in the go.mod file in the project root).
The gin code will be downloaded and placed in the pkg folder in your GOPATH (often ~/go). This way the code has to be downloaded only once, and every time you import it it is simply using the already present code. You do have to add it to the dependencies of your project every time though.
For more information about Go modules: https://zetcode.com/golang/module/

Adding laravel to an existing project that already runs with laravel on the web

Im very new to laravel and ive a project on a server that uses laravel.
How can i download this project and run laravel to it ? I managed to run laravel but it creates a whole new folder etc.
when i tried coppying the project folder to the laravel-created folder i got an error.
Download source code except vendor casus it's extra. Install php and composer. Then use a terminal(cmd in windows) and go to your project and run composer install. Wait till downloading packages complete. For running project type php artisan serve and your project is up. If your project had migrations and I think it has actually, run php artisan migrate before running serve command. Also check .env file in the root of project and change database credentials with your own. Depending on what dbms that project uses, you should install that DBMS too. Good luck
Taking reference to your comment:
i have the source code of a project that runs on laravel. Basicaly i am asking how can i run this source code localy on my pc
Good, that you have a project that runs on Laravel. You should probably consider to move your project to a central place, maybe Github, and from there create a proper workflow for development and further deployment to your (testing, production, ...) systems.
Even if you develop alone it would be a good practice to use git and Github - no, it is not the same
To come back to your original question:
How can i download this project and run laravel to it ? I managed to run laravel but it creates a whole new folder etc.
You don't need to install a new Laravel into an existing Laravel project. Just take the existing one.

Is it possible to exclude a package from update while using composer update?

I am using Neos CMS for my website. Now I am trying to update the CMS via composer update. Inside my project I installed a package that is now abandoned. That resulted in a failed update because the composer.json inside the package does not require the newer version of the CMS. Basically I just need a way to completely ignore that package while composer is updating. --no-dev did not work. That resulted in: Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems. Would be great if someone has an idea.
If the source of the abandoned package is still available, you may create a fork of it, change the requirement settings and then include your fork like described in How to require a fork with composer?
A much better way would be to exchange the package with something else which is still maintained. If you rely on the functionality of this package in your project(s), it may be worth to maintain an updated fork of it on your own.

How can I clone, edit & use a 3rd party Laravel plugin

I have scoured the web for hours but I can not seem to wrap my head around this. I am developing a Laravel project where I am using the dependency UniSharp/laravel-settings. However, I have noticed that after upgrading my Laravel version to 6.0, the package breaks. I have figured out what I need to do to make the package work with Laravel 6.0 and now I wish to make the required changes and then use the modified package.
So far, I have cloned the original repository into my own (i.e realnsleo/laravel-settings) and I have cloned it onto my development machine. The trouble is, I don't know how to test whether my changes work. Do I need to setup a fresh Laravel installation to test the package? I noticed the package has it's own composer.json file, should I install those dependencies separate from the installed Laravel project? I am highly confused.
Can someone assist me with a step by step on what I need to do to achieve this? I will highly appreciate it. Thank you.

How do I create an "add-on" package for my Laravel Project

I have a Laravel project that I have been building for a while now. I want to add features that are not part of the main application, but can be added on as Add-In packages, but I don't know the best way to do this. These packages will have their own routes, views, models, and controllers.
I have looked at https://laravel.com/docs/5.7/packages and other sites for creating Laravel packages, but the big problem is that with this setup the package is loaded via composer.json. Any time I update my main application and add a new dependency to the main project, it will overwrite the users composer.json with any add-in's they have registered.
Is there anyone who can point me in the right direction to do this?
You have possibly two ways to create your own add-on
Use this package to create modules with your own stuff-
https://github.com/nWidart/laravel-modules
Create your own package-
https://wisdmlabs.com/blog/create-package-laravel/
Your doubts regarding developing the package and losing the changes, is not true. Please read the guide mentioned above and do more research on how to develop a package in Laravel.
Or you can choose the 1st option which is easier and less confusing where you can create your own module in a separate folder and use it in your application. You can also share it as a separate module.
but the big problem is that with this setup the package is loaded via
composer.json. Any time I update my main application and add a new
dependency to the main project, it will overwrite the users
composer.json with any add-in's they have registered.
This is not true. You are confused about the overall use and functionality of composer.json.
When you create your own package/module, you have your own composer.json. You don't lose your changes if you add a new dependency or update your application.
Every time you add a new dependency or update your composer, your changes are updated on composer.json without wiping the existing package information. You don't have to worry about losing the changes.

Resources