Which files/directories to ignore in a Laravel 4 project when using version control? - version-control

I have a Laravel 4 project, and I would like to know which files should be ignored when using a version control software such as Git, Mercury or SVN?
The structure of my project looks like the following screen capture.
I'm pretty new to Composer so I'm not very clear about what goes to a repo what not. If someone can post their .gitignore file or their SVN ignore property, it could be handy.

For reference, that .gitignore file can be found here:
/bootstrap/compiled.php
/vendor
composer.phar
composer.lock # Remove this one after you create a project
.env.*.php
.env.php
.DS_Store
Thumbs.db
As noted in the below comment, you probably want to commit composer.lock in your project. Laravel ignores it by default so the authors of the laravel/laravel package don't accidently impose packages on you.
Your project should include the composer.lock file so you can install packages of stable versions (via composer install instead of composer update) properly in your production environments.

Note that the config file:
app/config/app.php
Has a cryptographic key in it that wouldn't be great to commit to a repository. Or, at least, the file needs to be overwritten in production.

You might also want to see the Laravel docs here and here. This discusses how to setup different Laravel configurations for different environments and protect sensitive information. All your .env.local.php type files should not be included in version control. Note that the .env.*.php and .env.php is added in the default Laravel .gitignore file. You can see it here

Laravel has posted their .gitignore on GitHub, which can be found here.
As of today, it looks like this:
/bootstrap/compiled.php
/vendor
composer.phar
composer.lock
.env.*.php
.env.php
.DS_Store
Thumbs.db

GitHub has a repository of suggested .gitignore files for almost all kinds of projects at: http://github.com/github/gitignore
Alternatively, you can search it for your project using this handy and extremely useful online tool: http://www.gitignore.io

Related

Does Xcode 11 and its new frameworks like SwiftUI demand changes to .gitignore?

I peaked into the .gitignore file that was in the SwiftUI example projects and found this. Should I add it to the current swift,macos template I pull from git? I'm not so concerned as I am curious whether it's superfluous.
I have copied and pasted it under the templates ##Various Settings xcuserdata/
This is what I copied:
/.xcodeproj/project.xcworkspace/
!/*.xcodeproj/project.xcworkspace/xcshareddata
/.xcodeproj/project.xcworkspace/xcshareddata/
!/*.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
/.playground/playground.xcworkspace/
!/*.playground/playground.xcworkspace/xcshareddata
/.playground/playground.xcworkspace/xcshareddata/
!/*.playground/playground.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
Nope. .gitignore tells git which files (or patterns) it should ignore. It's usually used to avoid committing transient files from your working directory.
You can find an official gitignore example for Swift here. You can use it, by default ;)
I also recommend reading about git: What is git

yii2 vendor and some files are missing from github

I have set up a new repo on github and pushed yii2 advanced template. Now i realized that some folders/files are missing from github like vendor and backend/web/index.php.
Anyone have idea why this is happening, i also checked my local git setup there files are present.
Check out the installation guide.
Running composer install is what creates the vendor folder, while running init creates those index.php files.
I have found that its happening because of .gitignore file. i removed it and its working fine for me.
It's quite simple idea behind missing these files, they are called ...-local.php, because their content can vary for different developers or production conditions. All you have to do before upload yii2 to the github, check the /environments directory, it includes templates for the local files, so after yii2 project is copied from the github, they will be generated by ./yii init.
Step-by-step, what should be done:
Configure files in /environments/dev and /environments/prod (for production). Most likely, if you don't change the yii2 project file structure or touch any of the /config files, you don't need to adapt them.
Update /environments/index.php, if you have updated /environments files
Upload the project to GitHub
Clone the project and run composer install to install dependencies
And finally run ./yii init from the root folder. You will see that ...-local.php files are now generated in certain directories the same way as they are configured in the environments.
More detailed information about this topic: https://www.yiiframework.com/extension/yiisoft/yii2-app-advanced/doc/guide/2.0/en/structure-environments

Bower does not sync dist folder in project dependencies?

When I synchronize bower components via github my bower_components apps is missing dist folders and the only solution is to uninstall package and install it again.
Is it any way to build all dependencies project and got those folders?
I know that maybe removing bower_components from .gitignore is not the best approach but I try to involve my sister in development and she always has issues running a project.
I would appreciate any help.
Thank you
From the info in the comments it looks like your .gitignore file is causing git to ignore the dist directories.
I suggest reading Checking in front-end dependencies before deciding whether to commit your bower_components to git.
Well,
I wanted to comment on drorb's post but apparently I don't have much of a rep :) You rock. nodejitsu looks at .gitignore and I was commenting out dist instead of /dist. It was essentially ignoring files that were within and bower_component that had a /dist/ directory.

How to update projects with composer support?

I hope the question is somehow explaining, what I want to do. If not, I'll try to give a more detailed explanation:
I am currently migrating a big project from SVN to Git. In this project, all the depencencies where stored in different folders and where commited to the SVN repo. I already learned, that you should not put the vendors folder in your repo. But how would I than update the depenencies? In another ressource I read, that you should only versioning the composer.lock file. How about the composer.json file?
Here is the strategy, I had in mind:
Excluding the vendor folder in the .gitignore file
Adding composer.json and composer.lock file to the repo
Adding a composer_update.php file to use it in a post-receive hook
When we have to update some dependencies, we have than to do the following:
Updating the composer.json file
Running composer update locally to update the composer.lock file (or the composer_update.php script in your local dev instance)
Pushing the changes to Stash/Bitbuckt/Github, which will than execute the composer_update.php script through the post-receive hook
Would you recommend something like this, or is there a better way to do it? I am sorry, but I am really new to composer.
You are supposed to commit both composer.json and composer.lock, as these two files are essential for Composer operation. I bet you misread on what not to commit - from all the things a run with Composer creates, you ONLY commit the lock file, and nothing else.
Commit both the composer.json and composer.lock file.
To update dependencies while development just run composer update in a terminal.
To update dependencies on production run composer install in a terminal. You may add this command to the post-receive hook.

Eclipse reference directory outside eclipse project directory but within repository

[Update: See comments]
So lets say I have a structure like this:
/trunk/src
/trunk/platform/linux/[eclipse project]
/trunk/platform/windows/[eclipse project]
I want both project to be able to see /trunk/src, open its files and use the automatic error highlighting on those files. I've tried creating Linked Resources to the directory. This works great with nasty limitations. It never updates unless you re-import and you can't create/delete files. I tried storing a symbolic link in the git repo which apparently as of git 1.6.1 no longer works. I tried anyway and upon cloning the symbolic link comes our broken.
This is really just for ease of access to the main codebase for a multi platform project. The solution need not be elegant but it is important. So I figure I can instruct each dev to just make their own sym link to the main codebase as part of dev environment setup. Tried and these symbolic links created with ln -s do not seem to appear in Eclipse nor can they be imported.
Finally I figured I could create a General Project in /trunk/ within Eclipse. Seems Eclipse is "smart" enough to warn me that this is not possible because it detects other projects deeper in.
Any help appreciated.
First, a comment:
'/trunk/xxx/yyy' is a SVN approach, where all branches/tags are "emulated" as directory.
You don't need them with Git. Two branches (one 'linux', one 'windows') are enough; then you can clone your repo twice, once in a 'windows' directory, one in a 'linux' directory.
Regarding a possible solution:
If the only difference between the linux and the windows platform, regarding eclipse, are the .project and .classpath files, I would actually recommend having only one repo (for your sources), with aforementioned two branches, each one including the sources and the eclipse files (tailored for each platform).
That way, the solution is much easier to maintain: one repo, one structure. Two branches.