What to include in gitignore for a Laravel and PHPStorm project?

前端 未结 4 892
挽巷
挽巷 2021-02-07 09:42

I\'m going to be collaborating on a project using Laravel and PHPStorm. After doing some research and working on a few projects, here is the .gitignore I\'ve come u

相关标签:
4条回答
  • 2021-02-07 09:51

    Unless PHPStorm is an official part of the project (e.g. it's mandated by a company, or agreed to by all team members) I would urge you to put its ignore settings into .git/info/exclude instead of .gitignore. The former is local to your copy, the latter should be committed and shared.

    gitignore.io suggests this for Laravel:

    # Created by https://www.gitignore.io/api/laravel
    
    ### Laravel ###
    vendor/
    node_modules/
    npm-debug.log
    
    # Laravel 4 specific
    bootstrap/compiled.php
    app/storage/
    
    # Laravel 5 & Lumen specific
    public/storage
    public/hot
    storage/*.key
    .env.*.php
    .env.php
    .env
    Homestead.yaml
    Homestead.json
    
    # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
    .rocketeer/
    

    and this for PHPStorm:

    # Created by https://www.gitignore.io/api/phpstorm
    
    ### PhpStorm ###
    # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
    # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
    
    # User-specific stuff:
    .idea/**/workspace.xml
    .idea/**/tasks.xml
    
    # Sensitive or high-churn files:
    .idea/**/dataSources/
    .idea/**/dataSources.ids
    .idea/**/dataSources.xml
    .idea/**/dataSources.local.xml
    .idea/**/sqlDataSources.xml
    .idea/**/dynamic.xml
    .idea/**/uiDesigner.xml
    
    # Gradle:
    .idea/**/gradle.xml
    .idea/**/libraries
    
    # Mongo Explorer plugin:
    .idea/**/mongoSettings.xml
    
    ## File-based project format:
    *.iws
    
    ## Plugin-specific files:
    
    # IntelliJ
    /out/
    
    # mpeltonen/sbt-idea plugin
    .idea_modules/
    
    # JIRA plugin
    atlassian-ide-plugin.xml
    
    # Crashlytics plugin (for Android Studio and IntelliJ)
    com_crashlytics_export_strings.xml
    crashlytics.properties
    crashlytics-build.properties
    fabric.properties
    
    ### PhpStorm Patch ###
    # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
    
    # *.iml
    # modules.xml
    # .idea/misc.xml
    # *.ipr
    

    As an aside, gitignore.io can be accessed via the command-line, so you can do things like

    gi laravel,phpstorm >> .gitignore
    

    It's a pretty handy little tool.

    0 讨论(0)
  • 2021-02-07 09:51
    rm -rf .idea
    git-ignore .idea/
    git commit -a -m 'deleted and ignored .idea/'
    

    Reload project.

    0 讨论(0)
  • 2021-02-07 10:01

    I use this smart .gitignore file ;) , Hope it may help someone:

    /node_modules
    # ignore log files and databases
    *.log
    *.sql
    *.sqlite
    # ignore compiled files
    *.com
    *.class
    *.dll
    *.exe
    *.o
    *.so
    # ignore packaged files
    *.7z
    *.dmg
    *.gz
    *.iso
    *.jar
    *.rar
    *.tar
    *.zip
    # ignore OS generated files
    ehthumbs.db
    Thumbs.db
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    # ignore Editor files
    *.sublime-project
    *.sublime-workspace
    *.komodoproject
    _ide_helper.php
    /.idea
    /.vscode
    # Eclipse project files
    .buildpath
    .project
    .settings/
    # Ignore cache
    .cache/
    # Ignore user created files :)
    *.bak
    *.orig
    # Ignore system files
    .bash_history
    LICENSE_AFL.txt
    LICENSE.html
    LICENSE.txt
    LICENSE_EE*
    RELEASE_NOTES.txt
    .ssh/
    error_log
    .htpasswds
    /.htaccess
    php.ini.sample
    .modgit/
    _vti_bin/
    _vti_cnf/
    _vti_inf.html
    _vti_log/
    _vti_pvt/
    _vti_txt/
    tmp/
    php.ini
    _old/
    .htpasswds/
    .htpasswd
    .viminfo
    .profile
    .bashrc
    .bash_logout
    .modman/
    pkginfo
    nohup.out
    Homestead.yaml
    Homestead.json
    /.vagrant
    .phpunit.result.cache
    #Laravel Specific files
    /vendor
    .env
    /public/.htaccess
    /storage
    storage/*.key
    
    0 讨论(0)
  • 2021-02-07 10:03

    Laravel automatically create it with installation:

    /node_modules
    /public/hot
    /public/storage
    /storage/*.key
    /vendor
    .env
    .env.backup
    .phpunit.result.cache
    Homestead.json
    Homestead.yaml
    npm-debug.log
    yarn-error.log
    
    0 讨论(0)
提交回复
热议问题