Let's build a Laravel Package - Publishing on Packagist

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone welcome back to lair economy it's make again and in this lesson we're gonna be taking the package that we built in the previous lesson we're gonna be putting it on github and hosting it on packages so that other users can download it so to give you a quick synopsis of the package that we created it was called PHP artisan joke and basically it would go out on the internet and grab a random joke and then bring it back so we could see it in the console so we can do as many times as we want and you can see it gets a different joke each time now if you didn't follow along you can grab the source code on github when we are done by the time this video is published it will be live so you can clone or sorry you could probably fork the repository and you could follow along with this video but for now I'm gonna go over to my dashboard and inside my lair Academy what I want to do is I want to create a new repository so I'm just gonna click the new button here and once github loads up we are gonna have the repository name as artists and joke and let me just go in to sublime text and grab that description just so we have it here alright so the description is in there this is gonna be a public repository and I'm gonna initialize it with a readme for now and it's also add a license of MIT just so we have something in there then normally what I would do is I would create the repository first and then I would clone this repository and do all the work in the repository itself and then commit but because we didn't really do anything that in the initial video I'm gonna just do the simple way because we don't have a lot of files here we can get away with this we can click the upload files and basically what I want to do is upload the artisan joke directory here so I want to open up my containing folder which has our composer Jason now also has some of the other files that we worked on here so all I'm gonna do is I'm gonna take everything in the main folder here just drag and drop it into github here github will then notice that we have the different folder structure and everything and it will put that in for us now I'm going to commit my changes I'll just say initial release version and I want to make sure that I commit directly to the master branch now sometimes we would make a PR and then commit it that way and do a pull request but for now let's just keep it simple and let's commit directly to the master branch so I'm gonna hit commit and get helps gonna process our files and then once it done once it's done we'll be back to the code version here so you can see that we have a little bit of readme we have the license in there and all of our code is automatically in there the next thing we want to do is switch over to packages and I've already logged into my account so create an account if you haven't what I want to do is I want to submit a new package so actually all I have to do is provide the repository and because I'm using github I can just take the URL here and I can just paste it into that repository then all I need to do is click the check function here that's gonna go and check for other packages that might be named the same and you can see that the package name found for your repository is this press submit to confirm so that is a hundred percent correct so I'm gonna hit submit and packages should take over and put everything here for us now if there was another package name the same you might get a little bit of a warning saying that there's other packages are you sure you want to continue but in my case there was only one package like this so we're good now on this page it is actually showing that the package is not on auto update so we need to set up a github service hook so we could click this and it will basically take us to the packages information for us but let's actually switch over to github and let's click on settings for a repository and what we want to do is go into integration and services and then in here we want to add a service and all we need to do is type in packages and that will show up in the list now after that we have to come down and we're going to have to fill in a couple different things here the only real thing that we it's gonna be the user and the token so I'll need to fill in my username and then my token and we can actually find them if you click on packages and then you go into profile I'm gonna do this off-screen just because they are private settings so now I have my user in there and I have my API token I'm just going to click add service and you'll see that it's gonna be automatically active when the event is triggered so I'm gonna click on add service and now basically github services home looks like we're doing this at a special time so this is actually in there and as long as everything is good we should be able to look at this and everything's in there okay so even though we have this warning here let's kind of push through it what we can do is on the integration we can test the service here so when we click that button a payload is going to be sent on its way over to packages so all we really have to do is wait a couple minutes we can refresh the page and once that test package goes through you can know you'll see that we no longer have that message there so what's actually happening behind the scenes is any time we release a an update for this package on github packages is automatically gonna see that because they're going to get they're going to get a payload and they're gonna update the information here so right now our package is live but we can't really download it so what we have to do on github is we have to create a release now the release is just going to contain everything that's in here so we can just click on releases and then we'll say create new release we'll set the version tag as 1 dot o and make sure that we are going to use the master branch we can give it a title so I'll just say initial release and if you had any notes any changes you would put them in here now I'm just gonna publish this release and once I do that what's gonna happen is github has told packages that there is a new release so if I come back over to packages right now you can see the only one that I have is dev master I'm not sure if we've waited long enough but let's reload the page see if that kicked in and it has so right now we have 1.0 package so what that means is now we can load up a default or any version of laravel that we have and try a composer install so let me actually create a fresh copy of laravel here and do a composer install so then with some editing magic I have a fresh copy of laravel here nothing has been installed or anything it's just a basic composer crate if I switch over to my terminal I can do a PHP artisan and you can see here we don't have the joke command in there and scrolling up a little bit higher you can see that we're running laravel 5.6 so what we're actually gonna do is do a composer require oops I'm gonna copy the name that I have here and I think we've waited long enough for the service to push everything else so we'll say composer require and we'll just paste that in and as long as we've waited the initial amount so are the amount of time it's taken for packages to push all the changes out it should be able to pull that in and you can see it's using 1.0 and what it's actually doing is it's gonna take all our dependencies so it's gonna pull in guzzle for us automatically and then once it's done level is gonna take over and do the automatic discovery and you can see right there we have a discovered package so that means that I should be able to look at PHP artisan now and if I scroll up to the top we now have our joke commands let's try and run that let's say PHP are some joke and hopefully it will fire off and you can see that we now have a joke so now everyone can come here and install this package and anytime that we make an update so someone says you know I also want to use this API the only thing you really have to do is once you make your code changes you really need to just do a new release so they all draft a new release and then once you have everything here you'll publish it and doing that will automatically update packages and everyone that has your package will be able to pull that in or do an update automatically anyway I'd like to thank you for watching at this point I'd like to say thank you for watching if you like what you see please consider supporting me on patreon and don't forget to subscribe to my youtube channel please help by passing the word around thanks a lot for watching
Info
Channel: Laracademy
Views: 2,028
Rating: 5 out of 5
Keywords: laravel, package, packagist
Id: NyivAeSU78c
Channel Id: undefined
Length: 9min 9sec (549 seconds)
Published: Mon Sep 03 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.