Here are some simple instructions on how to get Composer working along your Web Station package for app/web development.
Advertisement
Assets Used:
- DSM 6.2.x
- DSM Web Station (running nginx, but works with apache as well)
- DSM Package PHP 7.3 (you can use 5.6 as well)
- For composer to work properly User Home service is recommended to be active (Control Panel > Advanced > User > User Home)
Instructions:
- Open Web Station, go to PHP Settings:
- Check “phar” (PHP Archive support):
- Press “Apply“
- SSH your NAS, and issue the install commands (note: change folder accordingly to where you want to install it; example below will be in current directory):
sudo su php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
- If it fails to install, just grab the new commands directly from https://getcomposer.org/download/, as the hash (in color above) will vary whenever a new version of the file is released.
- You should see a success message as the one below:
All settings correct for using Composer Downloading... Composer (version 1.4.2) successfully installed to: /volume1/homes/adminuser/composer.phar Use it: php composer.phar
- It should run by issuing:
php73 ~/composer.phar
Additional Notes:
- Set composer to run globally:
sudo cp composer.phar /usr/local/bin/composer
- Make it run with a more recent package of PHP:
alias composer="/usr/local/bin/php73 /usr/local/bin/composer"
- [recommended] Make it ignore platform-requirements so that you won’t get php version warnings. Issue:
alias composer="/usr/local/bin/php73 /usr/local/bin/composer --ignore-platform-reqs"
- To update composer, use:
sudo composer self-update
Bonus: installing Laravel
- You’ll need User Homes service activated
- You’ll probably need to issue:
composer clear-cache
- Check if your ‘php -v‘ meets laravel’s requirements. If not, you will also need to point php to a compatible version (package needs to be installed):
alias php='/usr/local/bin/php73'
- Then you should be able to run the laravel global install command:
composer global require laravel/installer
- The binary will be located at
/var/services/homes/YOURUSERNAME/.composer/vendor/bin/laravel
- You’ll need to fix your project folder’s permissions (this is a simple consideration for a development server, not production – check this). Note that in a Synology DSM you need to consider http instead of www-data:
sudo chown -R :http . sudo chmod -R g+r . sudo chmod -R g+rw public/.
- When running commands, you may need to ignore package requirements, as laravel appears to be invoking php 5.6:
php73 ~/composer.phar clear-cache php73 ~/composer.phar self-update php73 ~/composer.phar update --ignore-platform-reqs php73 ~/composer.phar install --ignore-platform-reqs
- Here’s an example for successfully running the Auth components of laravel/ui on a Synology
php73 ~/composer.phar require laravel/ui --ignore-platform-reqssudo npm install && sudo npm run devsudo php73 artisan ui vue --auth
Advertisement