deployphp / deployer Goto Github PK
View Code? Open in Web Editor NEWThe PHP deployment tool with support for popular frameworks out of the box
Home Page: https://deployer.org
License: MIT License
The PHP deployment tool with support for popular frameworks out of the box
Home Page: https://deployer.org
License: MIT License
What about moving from procedural to OOP?
I'm thinking to drop support for PHP 5.4 for Deployer 3. And start with 5.5.
What do you think? ✌️
Possible to run simple shell commands directly without creating callback.
task(name, shellCommand)
example:
task('deploy:cache:warmup','php %releasepath%/app/console assetic:dump --env=%env% --no-debug')
This would automatically provide some default behaviour for a task, and could replace many simple tasks.
The current functionality for ReferenceTask could be removed to an alias function
function alias($name, $alias) {
Deployer::$tasks[$name] = new ReferenceTask(Deployer::$tasks[$alias]);
}
Got this error yesterday on my first try with deployer:
PHP Notice: No compatible server to client encryption algorithms found in ...../vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php on line 1127
I got it fixed by updating vendors and rebuilding PHAR archive.
Hope this can help :)
Although I have read the docs twice I still can't figure it how deploy using ftp server , could your please help in that ?
To be more consistent in naming...
All local commands are still actually executed when running the deployment with --dry-run because there is no "LocalServer".
(working on pull request, but requires significant refactoring)
The use of many static variables makes it difficult to write extensive tests for complicated scenarios or functionality or single functions
Suggest to change to a more test friendly
functions.php: use Deployer::get() to get the current instance
Deployer::$servers => Deployer::get()->servers();
Deployer::$servers['main'] => Deployer::get()->servers('main');
classes: the Deployer is needed in a few classes, so injecting it through the constructor would allow it to be mocked.
class RunTaskCommand extends BaseCommand
{
...
protected $deployer;
public function __construct($name, Deployer $deployer, TaskInterface $task)
{
....
}
}
{
"require": {
"elfet/deployer": "1.1.2"
}
}
Your requirements could not be resolved to an installable set of packages.
Problem 1
- elfet/php-ssh v1.0.0 requires ext-ssh2 * -> the requested PHP extension ssh2 is missing from your system.
- elfet/deployer v1.1.2 requires elfet/php-ssh ~1.0 -> satisfiable by elfet/php-ssh[v1.0.0].
- Installation request for elfet/deployer 1.1.2 -> satisfiable by elfet/deployer[v1.1.2].
it's possible add support for
https://github.com/badoo/pssh_extension ?
and maybe optional using python-style decorator a la Fabric
https://github.com/AterCattus/php-decorators
/** @parallel */
task()
In my case I have different ssh keys on my deploy host and my git repository. For that I use "forward_agent" option in ruby lib "net-ssh".
I have researched that and unfortunately found that libssh2 and therefore "pecl_ssh2" don't support forwarding agent. Only it prevents me to use "deployer" in my projects.
@Elfet Do you have any ideas how to bypass it?
I'm sure this was built with with Symfony in mind (heck its built using Symfony components), but to make is easier for people to adapt this to other frameworks could the most basic deployment steps like prepare, symlink, and rollback be in a separate recipe and then layer Symfony specifics on top of that?
For a freeform project instead of require 'recipe/symfony.php';
you could just require 'recipe/basic.php';
and get the meat and potatoes of the tool.
If you ever plan on shipping more default recipes for other frameworks this could also help cut down on duplication, since everything will leverage the basics, but each framework will handle assets and caches differently.
in src/Utils/Local.php, line 24
This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.
);
$process = proc_open($command, $descriptors, $pipes);
if (!is_resource($process)) {
die("Can't open resource with proc_open.");
}
// Nothing write to input.
fclose($pipes[0]);
Posted from SensioLabsInsight
I install deployer through composer:
composer require elfet/deployer:~1.0
after that I call
vendor/bin/dep
and there are only 3 availible options (help, list, self-update)
When call:
dep deploy
Error is Command "deploy" not exists...
On your website you make the following statement:
Deploy your code to all servers you want, it supports deploy via copy, or via VCS (like git), or via rsync.
However, I am unable to see how exactly one would deploy via "copy" or rsync. It is unclear from the documentation or from the source code.
Could you please give an example deploy.php file showing how this can be done? Or does one have to write the custom tasks running all the appropriate rsync or "copy" commands?
As I understand @Elfet is preparing for a v3 relase, which is great, but the timing is unknown.
I also think that having a more more stable release schedule, would allow new features to become available to the general public.
If we take the Symfony Release Process especially the rationale, although it is overkill for this project, we can reuse some parts of it. For example:
Also considering other console based applications, such as composer, although it has some beta releases, when updating composer it always updates itself to the latest master
version, which is perfect to roll out features.
I propose we start a discussion about this.
Trying to run composer install will produce this error message:
Installing kherge/amend (3.0.3)
Downloading: connection...
Could not fetch https://api.github.com/repos/kherge/php-amend/zipball/d191de606b3b76a28f09d97ddc04014426116965, enter your GitHub credentials to access private repos
The credentials will be swapped for an OAuth token stored in /Users/nicholasruunu/.composer/config.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: nicholasruunu
Password:
Downloading: connection...
[Composer\Downloader\TransportException]
The "https://api.github.com/repos/kherge/php-amend/zipball/d191de606b3b76a28f09d97ddc04014426116965" file could not be downloaded (HTTP/1.1 404 Not Found)
I'm trying to deploy using a private Bitbucket repository. I've set Git access via SSH as instructed at Bitbucket https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git
When I try to deploy it gives me:
[RuntimeException]
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Which means it connects succesfully to the server but it cannot access the remote repo. It's weird because I try to clone my repo manually and it works fine.
Hi,
Looks like the documentation page isn't working any more. The navigation on the left won't redirect me to another page on Chrome and Safari on Mac. It links for example to '/#examples'.
Hope you can fix this, so I can read a bit more about this awesome tool :-)
Thanks!
Jeroen.
Every task is executed with its own Environment when running with --dry-run, this makes it impossible to share env() variables between tasks.
(working on pull request)
I would like to download in my local env a sql dump.
I try to implement get from Net_SFTP class but don't work...
Here my work: https://github.com/miziomon/deployer/
Please can you implement this feature?
Thanks in advance...
I'm using the symfony recipe but would like to change one of the tasks. The way the recipe is written means there's no way of changing that task without needing to rewrite the whole recipe.
Is it possible to deploy multiple stages to multiple environments easily, like it's done with capistrano (cap staging deploy / cap production deploy)?
I'd like to deploy my staging git branch to another server then my master branch. Only this branch and the server settings need to be different.
Hi,
I just found your repository and play a bit with deployer.
However I have this error when I run php deploy.php install
PHP Fatal error: Cannot access private property Deployer\Tool::$tasks in /Users/william/my_app/vendor/elfet/deployer/src/Deployer/Tool.php on line 72
Hi,
I am trying to test this script but i get an issue (all the team get the same issue in the office):
I've follow your very simple doc and I get this message when I launch cmd :
[InvalidArgumentException] Command "prod" is not defined.
Usually we didnot have problem with symfony/console on our symfony project.
Is there a special step for windows (seven) we miss ?
Thanks
What do you think about to create default deploy
task for common recipe similar to http://deployer.in/#symfony-recipe for non symfony oriented projects?
I spent additional time to figure out that there is no such default task.
Also tasks in symfony recipe should be prefixed accordingly like symfony:assets
and so on.
I just been trying out the ability to specify a different branch for each stage as documented here: http://deployer.in/stages.html
I just checked out the master branch even though I configured the develop branch. It doesn't seem to do anything with the "branch" option you set in the deployer. I searched for term branch and got no results. Is this something that has not yet been implemented?
What do you think?
Hello,
With run, runLocally and uploadFile, if an error occurs no exception thrown
As many devs do, I'm searching for PHP replacement of Capistrano to be more consistent. Deployer seems pretty thin and clear. BTW there is another tool http://magephp.com/. So far one feature from it seems to me important: YAML configuration. Such language agnostic way makes life easier to non-php-dev users. I understand that Deployer API is very light to be used directly.
Also it's not documented how can be used different environment configs. In Magallanes it's more clear
.mage/config - the main general.yml configuration file is stored here.
.mage/config/environments - the environments configuration files are here.
.mage/logs - logs (if enabled) are saved there.
.mage/tasks - and custom tasks are stored over here.
https://github.com/elfet/deployer/blob/master/recipe/common.php#L138
I think there should be distinction like we have with shared_dirs
/ shared_files
.
Probably more intelligent way is to get rid of such difference and have only one shared
option witch will able to guess is given argument a file or a directory.
set('shared', ['app/logs/', 'app/config/parameters.yml']);
set('writable', ['app/logs/', 'app/logs/*', 'app/public/whatever']);
Slash at the end treated as directory, file otherwise. Asterisk explicitly says that it is recursive.
Deployer is hanging when running "sudo su -" command. I need to switch to sudo user to perform git pull and to change permissions.
$ vendor/bin/dep deploy
Preparing server for deploy.................................
Notice: No compatible server to client encryption algorithms found in /var/www/project/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php on line 1257
✔
Updating code...............................................✔
Creating cache dir..........................................✔
Creating symlinks for shared files..........................✔
Make writeable dirs.........................................✔
Normalizing asset timestamps................................✔
Installing vendors..........................................✔
Dumping assets..............................................✔
Migrating database..........................................✔
Warming up cache............................................✔
Creating symlink to release.................................✔
Cleaning up old releases....................................✔
Successfully deployed on xx.xx.xx.xx
Seems Deployer successfully finished but there is nothing on destination server.
Hi,
Would it be hard to implement a special task that runs only on one server (last one). Let's say i'm deploying application to 10 servers ... and want to run a task after all the servers are deployed. The task should run on last server in the queue.
I need to clear some remote cache server (throught an api call) and running it on all servers seems like a bad solution.
The easiest solution would be to add some kind of env variable that I could check by config()->lastServer() and run a task only if this returns true.
Best regards,
Pawel
I install deployer through composer:
composer require elfet/deployer:~1.0
after that I call
vendor/bin/dep
and there are only 3 availible options (help, list, self-update)
When call:
dep deploy
Error is Command "deploy" not exists...
The php-ssh dependency has a hard dependency on the ssh extension. Possible solution is to make php-ssh a suggest instead of a require.
Hello,
I do the following task
task('git:update', function() {
run('git fetch');
run('git checkout master-dev');
run('git pull origin');
});
Then I run the task on console (win 8, powershell). I've got the following message under the console
If you want to rollback run "rollback" task
[RuntimeException]
Switched to branch 'master-dev'
git:update [--dry-run] [--server[="..."]] [stage]
I checked the the server and it was run correctly.
Please let me know if it is a bug or somethings
Rgs,
Cheers
Phuc
Hi there!
First of all, thanks for this awesome toolkit! It really rocks :)
My production server has bash console. There is an issue with deleting shared folders in codebase. Somewhy bash does not expand "~" in the following command:
cd ~/webroot/production && if [ -d "~/webroot/production/releases/2014072705721/core/modules/error/media" ]; then rm -rf ~/webroot/production/releases/2014072705721/core/modules/error/media; fi
and does not delete the directory (so symlink does not work).
After googling I've found this: http://stackoverflow.com/questions/1685894/home-directory-expansion-within-an-argument
So I've changed the expression to this
if [ -d $(echo ~/webroot/production/releases/2014072705721/core/modules/error/media) ]; then echo 'exists'; fi
and it worked as expected.
Hi, I'm trying to test a deployment with ssh + git, but I cannot figure out the proper way to use my .pem private key that lets me SSH into AWS instances. This is normally done with ssh -i key.pem or similar. I've tried setting is as both a public and a private key, to no avail. Also it seems that deployer is not properly recognizing the fact that phpseclib is failing in this case.
Hey there!
I'm still trying to determine what permissions are needed on the remote server for using deployer?
The user I'm using is fo
, and the user Nginx uses is the standard www-data
. When everything deployed, checking the permissions it's fo:fo
, but shouldn't it be fo:www-data
? I've added the user fo
to the www-data
group. I just get a forbidden error when trying to access the site after deploying.
Any help is appreciated! Thanks!
Hello,
It would be interesting to be able to specify the deploy file as an argument to the "dep deploy" command, for example with "dep deploy --file acme.php".
I'd like it so I wouldn't put a deploy.php file in every project but have all centralized.
jmsche
I just tested out deployer with some sample data and I found that it does not upload any dotfiles (.htaccess ...).
On the on side of course it's good, because no gitfiles (.git, .gitignore) are pushed to the webroot but as I mentioned files like .htaccess are not uploaded. Could there be an implementation to support this?
One more enhancement ;)
runWithParameters('some.sh --param=? || anything_else ?', ['foo', 'zoo']);
Should be converted to
run('some.sh --param=`foo` || anything_else `zoo`');
$ vendor/bin/dep
Deployer version __VERSION__
This line requires PHP 5.5 according to these notes
I wanted to submit a PR but am still reading the code and familiarizing :)
Just a question: why Deployer does a non-atomic swap with rm
then ln -s
instead of creating a temp link and then doing mv -T
?
See: http://codeascraft.com/2013/07/01/atomic-deploys-at-etsy/
Thanks!
patie@iMac27:~/www/clients/xxx/project$ dep deploy
Preparing server for deploy.................................Password:
If you want to rollback run "rollback" task
[RuntimeException]
Illegal variable name.
Exception trace:
() at phar:///usr/local/bin/dep/vendor/elfet/php-ssh/src/Ssh/Exec.php:28
Ssh\Exec->run() at phar:///usr/local/bin/dep/src/Server/Ssh2.php:94
Deployer\Server\Ssh2->run() at phar:///usr/local/bin/dep/src/functions.php:115
run() at phar:///usr/local/bin/dep/recipe/common.php:37
{closure}() at n/a:n/a
call_user_func() at phar:///usr/local/bin/dep/src/Task/Runner.php:45
Deployer\Task\Runner->run() at phar:///usr/local/bin/dep/src/Console/RunTaskCommand.php:168
Deployer\Console\RunTaskCommand->runSeries() at phar:///usr/local/bin/dep/src/Console/RunTaskCommand.php:118
Deployer\Console\RunTaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Symfony/Component/Console/Application.php:887
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Symfony/Component/Console/Application.php:124
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:114
Deployer\Deployer->run() at phar:///usr/local/bin/dep/bin/dep:51
require() at /usr/local/bin/dep:4
deploy [--dry-run] [--server[="..."]] [stage]
in deploy i have only this (but tried also other ways) :
<?php
require 'recipe/symfony.php';
server('main', '1.1.1.1')
->path('/home/html/project/public_html/')
->user('patie');
set('repository', '[email protected]:xxx/project.git');
ip, path and repository are of course other in my deploy.php, there is other problem
im on latest OSX, PHP 5.4.16 (cli)
any idea where is problem ?
Please, add return output in run and runLocally.
Thanks
Hello, I'm trying to use deployer but I have an issue with the ignore command.
This is my list of files to ignore
ignore([
'deployment',
'cache/',
'log/',
'nbproject',
'sessions/operator/',
'sessions/webapp/',
'sessions/driverAPI/',
'sessions/driver/',
'sessions/mobile/*',
]);
But if I do this it ignore the entire folder for cache, log and sessions, instead of ignoring only their content.
Also if I just say ignore([ 'log' ]) it will ignore any folder with the name log in my project not just the one in root.
[after every '/' is a * but github editor seems to remove them or at least I don't see them in my browser]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.