How to push laravel packages and helper files through git - php

If I don't have ssh access and can't run composer command over server.
How can I upload laravel packages properly through GIT repository, so that my project will run without any problem .
I know If I remove vendor folder from root .gitignore then vendor file will up to the server.
But still I have doubt, I have to do other thinks also.
I am not good in git thats why before messing laravel I am asking this.

The general recommendation is not to commit the vendor directory, that's why Laravel ships with a .gitignore file that contains the vendor directory amongst other things.
However, there are situations such as yours where this is not possible, so in that case there is a nice section of the Composer Documentation that offers some advice on how you should handle committing the dependencies to version control:
Should I commit the dependencies in my vendor directory?

Related

Laravel 5 Package Development GIT setup

I have some great code I want to share....so I am moving code from my laravel 5 app into individual packages for use through composer/packagist.
This will also allow me to separate out code I only want in development and avoid deployment of nasty database modification classes to production.
I am confused on setting up git. My main project is running on a git repository. I am developing the packages under a sub-folder named packages/myname/package_name1/ . Each package is going to want its own git repository.
Should I add the folder "packages" to my .gitignore file for my main repository, then set up a git repository for each subfolder?
I followed this tutorial: Setup Laravel 5 Package
If you're using composer/packagist then yes, you should add the folder packages to .gitignore on your main repository. When deploying the entire application or when updating a package you'll have to do a composer install/update to keep everything up to date.

I can´t get all folders from my branch on GIT

I have a git project with one branch, I´m trying to clone all files in my local folder, but I can´t get the vendor folder. I would like to know if I can do it in other way to get also vendor class.
I´m running this:
git clone -b branch_name repo_URL
As I say, I don´t get one folder. What I need to do it to get all files?
PD: I can´t download a ZIP of the project.
You are not supposed to find that vendor folder in your repository. It would be useless redundancy.
In modern PHP projects, Composer is being used to manage external dependencies. When running composer update, it reads a file composer.json (which should be present in your repository) to find the most recent versions of the external packages to be used.
This creates a file composer.lock (which should also be in your repository) with the exact versions and commits that got downloaded. If at any later time someone (like you now) wants to recreate the contents of the vendor folder, they run composer install, which will try to get everything that was once downloaded.
So the first step for you is to download Composer, then run composer install (depending on your way of downloading, it might also be php composer.phar install or something close to that).
Reasons for composer install to fail is that dependencies can no longer be downloaded because they were removed from the internet, or that the project is too old and has too old versions of said files so that it does not run with current versions of Composer (although this should be very rare). In any case: If you encounter errors, ask a new question here with all the details, including the full output of the Composer command.
The reason why you don't get the vendor folder is because the vendor folder never went up to the git repository. If you see the .gitignore file, you will notice a :
/vendor
This tells git to ignore that folder and not to send it up to the git repository when you are pushing. There is no way for you to get that folder unless you find the original project before you pushed to the git.

Laravel 5 setup git repo for multiple developers

I've done lot of Google but still looking for solution, I'm working on Laravel5 project & wants to set it up with GitHub so multiple developer can work on it.
I've install Laravel & place in a repository on Git, Now I cloned it on my local machine & another developer also clone that repository in his machine and start working.
But issue is that, I have installed a package for HTML forms in my machine by composer & push my code to github. But when another developer pull the repository then his code is break because composer.js is updated for that package but actually that HTML package is not exists on his machine.
Can anyone help me to short out this, or is there any way so we ignore vendor folder, composer.js, app.php etc files during git Push?
To answer your question specifically, yes you could choose to ignore the vendor folder, composer.json and app.php files when you push to git. To do this, you would simply need to update your .gitignore file to reflect this. I.e, include these in your .gitignore:
/vendor
composer.json
/config/app.php
But then the next question is whether you really want to do this, as doing so would mean that changes you make - and any subsequent pushes - may not be compatible with work the other developer is doing down the track.
If you exclude the /vendor file and the /config/app.php file but leave the composer.json file in there now that the other developer already has a copy of the core files, the updated composer.json file they download would allow them to use composer install to update the project with the new package.
However all of this would be problematic for a developer who joins you down the track and doesn't have any of the current files.

what files to save to repository laravel - framework workflow

Let me just say this, I'm very new to composer and laravel.
I'm a long time cli fan, so I feel very comfy with composer. I've used npm, ruby gems etc, I see all the benefits to package managers.
Problem is, I'm saving entire laravel dir to my svn repository. It seems kinda redundant, especially vendor/bootstrap dirs.
I also find it uncomfortable to have vendor packages same in every laravel app directory on the same server, I'm kinda missing global gems thing from ruby.
How do you deal with this? Is it possible to have laravel like a shared library on server and then just have app/public directories in each project?
What files should be saved to repository? can composer handle all the dependency installation on production server? I see laravel files come with .gitignore files, where do I get svn version?
Much confusion atm in my head, hope to clear these up, so I can start actually writing code ^_^
First off, as far as I know, it is not easily possible to install laravel and it's dependencies globally. I wouldn't worry about that too much though since composer will cache them so it won't need to download everything for each project you set up.
Vendor directory
The vendor dir should definitely NOT be in your repository. I'm no SVN expert but according to this answer you can ignore directories by doing:
svn propset svn:ignore "vendor" .
Most SVN client software should have a similar function in a context menu or similar.
Deploy workflow
Ideally you checkout the repo on your production server and then run composer update to install all dependencies. If you don't have terminal access or have other troubles with that I recommend you download a fresh copy of your repo and run composer udpate. Then upload it to your server.

Using Composer packages in a FuelPHP app managed with GitHub

I have a web application that I built using FuelPHP which is hosted on a private GitHub repo.
I recently added JAXL and APNS-PHP to the project using Composer. Specifically, I created a composer.json inside of the fuel/app directory with these contents:
{
"require": {
"varavan/apns-php": "dev-master",
"abhinavsingh/jaxl": "3.*#dev"
}
}
I ran composer update and everything works fine on my local development environment. I can push to GitHub just fine from the command line also.
However, when I pull on the public server, the newly installed composer packages are not included in the pull, although their directories are created. Specifically, these directories exist, but are empty:
fuel/app/vendor/abhinavsingh/jaxl/
fuel/app/vendor/varavan/apns-php/
If I look at those directories on GitHub, they don't look like directories. They've got an icon that I don't recognize:
Also, if I click on "Sync Branch" from the GitHub GUI app, it gives me this message This has been resolved, see update below.
The submodule at 'fuel/app/vendor/abhinavsingh/jaxl' was removed from
.gitmodules, but the folder still exists in the repositroy. Delete the
folder, commit the change, then try again.
WHAT!?
I used composer to install JAXL, not Git.
If I run composer install on the server, it says:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
But the JAXL and APNS-PHP directories are still empty.
How do I get the composer packages onto my production server?
Update
I added this to my .gitmodules file:
[submodule "fuel/app/vendor/abhinavsingh/jaxl"]
path = fuel/app/vendor/abhinavsingh/jaxl
url = git://github.com/abhinavsingh/JAXL.git
[submodule "fuel/app/vendor/varavan/apns-php"]
path = fuel/app/vendor/varavan/apns-php
url = git://github.com/varavan/ApnsPHP.git
That fixed the error that the GitHub GUI app was giving me, but I still can't figure out how to get the composer packages installed on the production server.
I continued to try everything I could think of to get the composer packages loaded, but I couldn't figure it out.
After adding the submodule definitions to my .gitmodules file, I deleted the entire project from the production server and re-cloned the whole thing from GitHub. The submodules came along for the ride.
It's not the composer way of doing things...
Whatever. What a waste of time.
Composer uses git, especially if you specify you want a development version. It will get it directly from the source.
And if you create a second vendor folder inside app, and Composer has added a git repository there (because of what you specified), git will detect a repo-in-repo, and since submodules are active for Fuel, it will assume you're adding a new submodule.
Like Martin Bean said, make sure you exclude the vendor folder, to prevent this from happening.

Categories