I developed a Laravel package which is currently located in the vendors folder of my Laravel 5.3 installation.
I am trying to put this package on GitHub so other people can use it. Also I want to be able to sync this package only (not the entire Laravel project) to the GitHub repository so I can commit any changes later.
What steps should I take to put this new package for the first time on GitHub and how can I keep the local project synced up with the version on GitHub?
Please have a look to this: (You most likely want to create a composer package)
https://knpuniversity.com/screencast/question-answer-day/create-composer-package
To put the package on GitHub follow these steps:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
To keep the project "synced up" commit and push changes that you make to the Laravel package, and they will show up on GitHub.
git add .
git commit -m "commit message here"
git push
Note: git add . adds all changes.
Use git add [filename] to add specific files.
Laravel works with composer package manager so you have to make a composer package
from the Composer Official Documentations :
A repository is a package source. It's a list of packages/versions.
Composer will look in all your repositories to find the packages your
project requires.
By default only the Packagist repository is registered in Composer.
You can add more repositories to your project by declaring them in
composer.json.
so all you need is a composer.json which contains your Project files here is a good tutorial for creating your very own packages
create-composer-package
Related
There are some frameworks like laravel which recommend installation using create-project.
It would be hard to update projects like this through composer, because
The composer create-project creates the skeleton with all initial
routes in your configuration etc.
From the very very first moment you are starting to change the default
routes, removing the default controllers and changing the default
views, your project would be out of sync. because meanwhile laravel
changes the skeleton to newer versions with some new default routes
etc or event changes directory structure.
However, I've recently seen that phpmyadmin recommends composer create-project as a possible installation method.
As phpmyadmin does not simply provide some skeleton files to be modified by the user, but a complete, finished web-app, I'd like to know what's the best way to update a phpmyadmin installation created like that?
I don't know whether there is an official way to do this.
According to the docs, create-project is the equivalent of:
doing a git clone/svn checkout followed by a composer install of the vendors.
If you haven't modified any of the files, I think the easiest way would be to just delete the directory and run composer create-project again.
If you have modified some of the files, you could do a git merge (if the project uses git) and run composer update again.
If you haven't yet created the project, you could run create-project with the --keep-vcs flag and then every time you want to update it, you can cd to the project and run:
git pull origin <version>
composer update
If you have already installed the project without --keep-vcs, then you'll have to make the directory a git repository and then add the project's repository as remote. To find the project's repository, search for it on Packagist. For example, for phpmyadmin:
cd phpmyadmin
git init
git add .
git commit -m "Add initial files"
git remote add git#github.com:phpmyadmin/composer.git
git pull origin <version> --allow-unrelated-histories -Xtheirs
composer update
Some of your changes might be lost with the above git pull though so make a backup (and maybe research other ways to merge unrelated histories).
I am thinking to create a project skeleton in the following format via a composer package that I am going to create.
/app
/config
/web
/vendors
Just wondering about this command
composer create-project vendor/name path
--repository-url=http://repo.yourcomposerrepo.com
What do I need to put in the composer.json in order to create the file structure I want? Is it done through the shell script or it just copied the files from the repositories?
For symfony it will create the files and folders automatically through composer create-project. Just wondering how do I achieve the similar thing for this case. When I looked at their repo it only contains one composer.json at https://github.com/symfony/skeleton
composer create-project symfony/skeleton blog
Thank you.
composer create-project will create a new directory with all the files that are part of that package and then it will run the installation for all the dependencies that are listed in that package's composer.json file.
If you want to have a better example to understand that, you can use the old way that we used to bootstrap Symfony applications (when not using the Symfony installer). Then applications were based on the Symfony Standard Edition which you can find on GitHub. Just run composer create-project symfony/framework-standard-edition and compare the result with the repository.
Using symfony/skeleton as the base package is a bit special. This package depends on Symfony Flex which is a Composer plugin that automatically applies so called recipes (see https://flex.symfony.com/) which will lead to newly created files when a package is installed (and clean them up on removal). But, this behaviour is special for Flex and thus nowadays Symfony 4 based application and not a good example for what composer create-project does by default.
I install a new Laravel project and I have been applied Many changes on it for my own purposes. for Example my custom admin panel design and related css and javascript files.
In addition to, I added some packages that are required on whole project.
Now , if I want to Start a new Project , I must to install a fresh laravel Project and add those files and packages manually again that It takes a lot of time.
Is there a way that I could store this base laravel project on it (for example Github) and install it via composer?
Yes, you can use Github to create a private/public repository then when you start e new project you clone that repository and then use composer install command to get the dependencies.
Yes, it's possible.
Here are all the steps :
git clone xxx.git
composer install (make sure you have included .env.example in your git for the app key)
npm install
bower install
php artisan migrate (if, I hope, you use migrations)
gulp
And you are ready to work on your project.
I have a PHP project with some 3rd party developed dependencies and some developed by myself.
Some times I happen to find a bug on one of the dependencies I maintain and want to patch it on the spot or code some extra functionality that fits the main project needs.
Right now I am coding on the module project, doing a commit and then a composer update on the main project's composer.json, whose source for the module is the remote repo.
I would like to be able to have the full dependency repos on the main project, or at least commit to local and get the update without pushing to remote.
I believe I can use composer create-project for that, but the problem is I also get a lot of rubbish (the 3rd party dependency repos) that make my project huge.
Is there any way to have a composer create-project that only downloads the full repo of the dependencies I choose (those developed by myself)? Or to have the repo url point to a local git repository folder instead of a remote one?
According to the manual, create-project
is the equivalent of doing a git clone/svn checkout followed by a
"composer install" of the vendors.
Considering that, you run
composer create-project --no-install
Then you add local repos in composer.json (I'm not sure if it is documented but you can provide absolute and relative local paths as repo url) and do
composer install
I already know how to install by going through composer.json to add laravel/cashier, then composer update, and then add some line in app provider. But where does this folder go? What other things does it add in my app to make it fully functional? What is the work flow of composer update in Laravel 4?
Composer is a dependency management tool for PHP. It is not a typical package manager as it does not install libraries globally, but on a per project basis. It uses the file "composer.json" to install, update and remove libraries specified, including the version requested.
Composer creates an "autoload.php" file that, if included in your project, autoloads all libraries and classes and makes them available for use.
Typically, in a regular PHP project, you'd include the following line to bootstrap your project:
require 'vendor/autoload.php';
Now, when you execute composer install (for first time) or composer update (every time after), Composer adds/removes packages according to configuration made in "composer.json" file. All packages go in the directory "vendor" found in root of your project directory.
Laravel, by default, is a Composer project. You know when you execute composer create-project laravel/laravel my-app --prefer-dist to install Laravel, you are telling Composer to build a "composer.json" file with Laravel project and its dependencies, and run composer install. That's all!
Last but not least, Laravel, since it is a Composer project, includes "autoload.php" file and autoloads all packages within that project by default. You will notice "vendor" directory in the root directory. In Laravel 5 project, if you navigate to "bootstrap/autoload.php" file, you will see Laravel includes "autoload.php" file: require __DIR__.'/../vendor/autoload.php';
To answer your question about manually installing Laravel Cashier, Laravel Cashier is a package made specifically for Laravel, and as such, is not meant to be used on regular PHP project, unless you use specific classes and do some tweaking. To manually install Laravel Cashier, if you go to the following link, you will find link to "laravel/cashier" GitHub repository, from where you can manually download Zip file or clone the repository using git:
https://packagist.org/packages/laravel/cashier
I hope this adequately answers your questions - I kept it as simple as I could. Let me know if you have any other questions.