I want to start a new repo on a current project I'm working on, the idea is to have a repo with, say 60% of the files in my project as a template so I can quickly clone it if I need to (I guess I could use gitignore to achieve that but maybe there is a better way of doing it).
For example:
- Website 1 contains these files/folders:
index.php
app/
config/
css/
I want index.php and app/ to be in the repo as the code will be exactly the same for all future websites I clone. But I need config/ and css/ to be unique to each website.
So now if I go to Website 2 and clone the repo from website 1 I would get index.php and app/ but nothing else, which means I would have to copy all other files manually, Is the a better way to do this?
The reason being that when I upgrade files in the repo I can quickly pull/fetch them on the other clones without affecting the unique files, if that makes sense.
Maybe there's a simple way of doing this.
Yea,
Copy what you want your new template repo to contain into a new folder structure and then create the new repo from that.
If the files are ignored, then you cannot get git to pull them.
If you are really desperate, you could make a new branch, where you remove the gitignore file (or the corresponding rows), then commit all files and pull them from the other server.
After that, you reverse your commit on webserver 1, or you unfollow css, config files.
On webserver 2 you would need to manually unfollow the css, config files too after the pull.
I would rather copy the files manually.
Related
I am working with composer and I've recently started a new project which requires it. No big deal since I've downloaded the json file and vendor folder and whatnot in another project.
Except I have to copy the composer files from my original project's directory and paste them into the new one. Is this the correct way to go about using composer or should I have the files contained within a single external location and referenced by each of my projects?
I'm aware that this is slightly off topic but I couldn't find a straight answer elsewhere and would appreciate advise on the matter. Thanks.
What you did is okay. Every project folder should have its own composer files. That way, updates or changes to dependencies are isolated per project.
This could be an advanced topic where you can modify php.ini's include path.
You do not need to copy composer vendor files per project. You can specify 'global' as parameter, which will save vendor projects in a global path.
Then, tweak your php.ini's include_path include that global path's autoload.
require_once("vendor/autoload.php");
Do NOT put a './' prefix as './vendor/... and the file is included from the global repository. This is a per-user configuration and may be allowed on your linux console.
Your project's json file is attached within the project itslef, but the vendor path is from global. Many projects can share the same repository. It may not impact the performance too much, because autoload does its best.
I am just starting to learn Laravel and have some questions about the directory structure, updating with composer, gulp, bower, the "public" folder, "resources", etc. Sorry, I am a newbie.
I got a Laravel Admin template online, so the setup there may be different than the raw install, but it seems basically the same:
app
bootstrap
config
database
public
resources
storage
tests
vendor
My question regards the assets folder under public and the assets folder under resources. The template that I have uses gulp and bower, so my question is if I change some css or javascript for one of my files, should I do that in the /resources/assets path or the /public/assets path ? Seems like you should update the resources and then do update with bower and gulp, otherwise your changes could get overwritten. Does that apply to everything in the /resources/assets path ? Update there and then update your /public/assets path ?
It does seem a little strange that the resources folder is essentially your development assets that can be compiled, but the views are in the resources folder, not the public folder. Is that because they are xxx.blade files.php files, development files and are sort of compiled into xxx.php virtual files in the public directory at runtime ?
You use Gulp and Bower to compile your custom assets in a more efficient way. If the template you downloaded makes use of these tools then you need to make your changes in the source files you feed Gulp/Bower and they take care of the rest and place the results in /resources/assets.
The /public/assets folder is where you or the template you downloaded save assets won't be edited by Gulp/Bower and can be accessible from the root path of your project. What ever you edit here will be kept like that until you make any manual modification again.
I wonder if is possibile to "move" the vendor folder to another location. I mean, I've a structure like this
/
Laravel Project 1
Laravel Project 2
Laravel Project 3
[... others ...]
CDN (For vendor if I can)
Well as you know every project comes with the vendor/ folder. I want to move that folder inside the CDN and "merge" all the requirements for every project in another composer outside the projects folder (inside CDN i guess).
Why this?
Simply because I've notice that vendors folder are nearly the same for every project so if I can combine all the "differences" in one single big vendor folder I can manage all the dependencies in one single location, pretty cool
Is that possible?
TY for any help :) Have a nice day.
In Laravel you can change the folder your applications load the framework and dependencies from bootstrap/autoload.php.
There's a require __DIR__.'/../vendor/autoload.php'; line in it and you can change it to whatever you need.
Thus you can change it to some outside folder, common to all projects.
Can somebody explain in brief the use of assets folder in yii framework. I am new to yii framework
Many newcomers ask: "What do we do with the assets folder?", and the answer is "Mostly nothing".
It's important that the directory be writable by the webserver user so that Yii can publish the resources there when needed.
When a project has multiple versions (production, testing, development, etc.) do not copy the assets/ folders from one area to another; allow Yii to deploy them automatically in each area.
Do not manually edit any file under assets/ - if you have a real need to make a change, find the publishing module, edit the source, delete the subfolder under assets/, and let Yii re-publish the updated files.
Do not reference names under the assets/ folder directly (say, to get at some other module's assets). If you need to use that
Do not add the contents of the assets/ folder to any source-code control system; these files have master source in other places.
It is safe to delete everything under assets/. Yii will re-publish the assets if they are not found under assets/.
Additional info
Yii makes assets accessible by Web clients, so the goal of copying assets to a Web-accessible directory is fulfilled and returns the corresponding URL for accessing them.
Read it from http://www.yiiframework.com/doc/api/1.1/CAssetManager
Issue: Nest a git repo in a git repo WITHOUT storing the second repo in the hosts master repo. The repos need to be two separate entity's. This way I can easily update a client sites base code (used on multiple sites).
Reason for two repos: I have a base php framework that my projects use. Each client gets their own repo that has the files required for that site. Due to the way git/submodules work I have to keep the "framework" as the master repo with the "clients code" as the submodule. The reason is I MUST have the index.php & .htaccess (part of the framework) in the root. That's fine since my framework is designed to extend as needed. I can just put any client files I need in the "site" folder and store that as a separate repo. The obvious downside is in order to setup the site you have to first install the "framework repo" then install the "client repo". Since these are private this setup is fine. I also liked the benefit of being able to update my framework from another project. Trouble is now any push's I do from that clone include the "client code". Also since I need the same setup for my local test of the framework that submodule gets added back to the main framework repo. I thought well why not just clone the "site" folder that holds the "client code" and add that folder to the ignore list. I have to update each by hand but again thats fine. However torisegit seems to think that its now a subproject (limited support) and I cant even add that folder to the ignore list. So i'm assuming nesting git clones is bad but I could be doing it wrong.
Goal: I need to be able to deploy two repos. My "framework" im sure has to be the base/root repo. Then I need to embed somehow a second "client" repo in a folder inside the base repo. The "client" repo never stores the framework code, just its own code. I want to be able to update and push changes to the "framework code" (its alpha so lots of bug fixes) without it storing anything about the "client code" so I can easly just clone it into a new folder for a new site. Again client code is stored in a single folder one level up from the frameworks root. (See example below). Doing this as a git clone breaks TortoiseGit and possibly git when I try to copy paste a folder and even add it by hand to the ignore file. Adding it as a submodules adds it to the master repo so when I clone it trys to add it.
Final Thoughts: Perhaps subprojects would work but there does not seem to be much support for it and I dont understand how to use it. Im trying to keep it to major tools so that my two main tools TortoiseGit and NetBeans support everything. Perhaps there is a way to not store a submodule in the master repo but I cant find it. Maybe subfolders would work but again there does not seem to be much support for it. Seems like the simplest would be it just ignore the folder but at least TortoiseGit seems to break when I try this but I could be doing it wrong.
Example Folder Layout:
-.git (framework repo)
- system *framework folder
-- foo *framework folder
-- bar *framework folder
- site (root for second repo aka client)
-- .git (client repo)
-- config.php *client file
- index.php *framework file
- .htaccess *framework file
The "system" folder, index.php and .htaccess are part of the PHP framework and are generic to all my sites. The "site" folder holds the second repo that contains the files for that site. The second option is to rewrite my framework so that its stored in its own folder and gets called by a new index.php. However this is a major rewrite with a pathing nightmare do to the way its written. Plus the issue of dealing with the .htaccess file since that has to be in the root. Sure I could copy it but then any changes to that file would not get updated in a pull. But at this point i think its the only way.
Hope this makes sense. I'm out of ideas but really want to get this to work.
You can always just clone the second repository where ever inside the first you like, then add the second's folder to your .gitignore file.
In your example above, you'd just add:
site/
to your .gitignore.
Git Submodules is the best thing I can think of. Check it out here. It's very handy for splitting up code into reusable repos too.