intellij: how to deploy to two folders? - php

The general question is: how to work with many different git repos at the same time in one intellij project. Where the git repos need to be inside the main application (that is one git repo too). I cannot use symlinks because I cannot commit those
I have 2 git repos
one is for the main app, the other one is for a library I am using in several projects.
Here is how it goes: I have the main app. Via composer I add my library / package to the application.
The problem:
folder structure:
to develop
IdeaProjects/myappA
note: there is are as well IdeaProjects myappB etc
IdeaProjects/mylib
in myappA there is
IdeaProjects/myappA/vendor/mylib
server deploy folder:
/var/www/www.myappA.com/
I do a lot of changes to the library, I have it open as another module when I work on myappA so I do code changes to mylib in that folder / module that actually contains the original source code of mylib. Now i don't want to composer install or update each time I do a tiny change. So what I do is I deploy via intellij the files from the library mylib each time on save directly into the composer install folder of my main application e.g. to IdeaProjects/myappA/vendor/mylib. Now the problem is, I need to deploy it as well to the server deployment folder. But there seems no way to deploy files to two folders out of the box with intellij.
What else can I do?
currently I manually use a short key to trigger an ant build that then copies the folder IdeaProjects/myappA/vendor/mylib to the server deployment directory.

There are multiple solutions depending on your setup:
solution inside intellij: just import mylib as a module inside your myapp project
Go to File > Project Settings > Modules, click the + and choose import module
git native solution: Use submodules
Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.
Note that there are some quirks when working with submodules, especially the way to keep the referenced submodules up-to-date
For completeness: if you were using gradle or maven instead of ant, you could use their respective projects views and use the + to add multiple build.gradle or pom.xml files, which would automatically import those projects as modules into intellij.

I think the module approach does fit your case and yes you can have a different git repo per module. Right click on your project root new->module or file->new module from existing source
Intellij should also detect every git repository automatically in your project if you check Settings | Version Control you should see the list.
You can also speed up some operations such as git pull instead of having to pull from every repository (VCS -> Git -> Pull) you can do VCS -> Update Project or ctrl-t (cmd-t on mac)

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.

How can I store my cakephp project in git?

I would like to store my new project in my company's git repo. The project will use cakephp 3. But frequently after setting up a project and pushing it I get some trouble: A coworker clones the project to his pc and it comes with missing directories (mostly "vendor"), and we frequently get problems with debug kit (need to remove the database file after every git pull).
Is there some recommended procedure to create this kind of project?
The recommended strategy for composer-backed PHP projects is as follows:
Add the vendor directory to gitignore.
Commit composer.json and composer.lock.
When your colleague begins development they just need to run composer install, and the committed composer.lock file will result in the right dependencies being downloaded.

What's the correct way to init yii2 framework with push-to-deploy

I've created post-receive hook for git repository which checkouts commit to web folder /var/www/myproject. Since I'm not committing dependencies (framework files), when checked out I have to install dependencies and init the framework. I see two approaches:
1) When checked out run the following commands from the project directory:
composer install
php init --env=Development --overwrite=n
#other commands to setup db connection, credentials etc.
2) Install dependencies one level up of checked out project /var/www and have links one level up. But it seems that with this approach I'll still need to run php init.
What's the common approach for such deployment?
An important feature of the advanced app is having separate backend and frontend apps. So if you check out your repo to /var/www/myproject, two important directories will be created: /var/www/myproject/frontend/web and /var/www/myproject/backend/web. You usually configure your web server to have these two directories as web roots for two different domains (like example.com and admin.example.com).
Yii2 advanced app introduces the concept of "environments". An environment is basically a set of config files, that, among other things, include db credentials. So if you don't mind having credentials in your repo, push-deployment is possible.
So if you plan to have multiple servers with multiple configs, you just create an environment for each server and use it to deploy.
So here are the steps you need to take after checking out the repo.
Install composer dependencies: composer install
Pretty straightforward. Keep in mind that fxp/composer-asset-plugin needs to be installed globally for composer to fetch bower and npm dependencies.
Check out a certain environment for current setup: init --env=your_server_environment --overwrite=All
You should overwrite everything. If you have updated some parameter in your environment, it will be applied to the current setup.
Migrate the database: yii migrate --interactive=0
That's all there is to it.

How do I deploy a PHP site to Azure websites from a subdirectory of a Git repository

I have a Git repository which contains an ASP.net application and a PHP application, each in its own subdirectory under the root of the Git repository. I would like to create two websites in Azure websites and deploy each of these applications to one of those websites. I can deploy the ASP.net application with no problem by setting the project variable in the settings panel on the website properties to the path to the CS project file. However I cannot successfully get the PHP site to deploy. I have tried setting the WWWroot directory, but Azure is still trying to build the csproj file even though it is not specified by the variable on that website, nor is it present in the root directory of the Git repository. How can I make the PHP site deploy correctly, without needing to put it in its own repository?
Figured it out: I just set the "Project" attribute in app settings to the directory name of the PHP application, relative to the root of the repo.
In case it helps, I used to do this on a number of my projects, but have since migrated to a new strategy.
Now, I create a git repository for my overall project and repositories for each of the "sub projects" within it. For my Tweet Monkey project, for instance, I have http://github.com/codefoster/tweetmonkey as well as http://github.com/codefoster/tweetmonkey-raspi, http://github.com/codefoster/tweetmonkey-edison, and the website at http://github.com/codefoster/tweetmonkey.io.
Then I link the sub projects into the main project using submodules by typing the following at the command prompt...
git submodule add http://github.com/codefoster/tweetmonkey-raspi
git submodule add http://github.com/codefoster/tweetmonkey-edison
git submodule add http://github.com/codefoster/tweetmonkey.io
That way I can deploy the website to Azure using CI by simply tying up to the tweetmonkey.io repository, but I can also clone the entire project or point other people to the entire project using the http://github.com/codefoster/tweetmonkey link.
Hope that helps.

Set up a github repository for an existing LAMP set up

I have a webserver setup using the standard linux, apache, mysql, php config and I currently don't have a way of doing revision control - I just backup the whole thing every now and then. I'd like to set up a github repository for just the php and html files - basically everything in public_html. Not really sure where to get started or how to approach it... I guess I could just set up a git repository in the public_html folder itself but that doesn't seem ideal...
Set up a Git repository one level above public_html ( git init; git commit -a ). Simple and easy (Git only creates one folder wherever you create it); you don't need to use Github (which is a publicly accessible Git repository).

Categories