Create installation file for any PHP project - php

The title can be a little bit misleading but this is what I need to achieve.
I have a project which resides in Github. I need to install these files in multiple domains.
So just like wordpress I need to have a simple PHP installation page where I take all the necessary details like site name, DB username , DB name etc and when I click install button it is going to do the following.
> git clone the project files
> create new directory
> Run composer install (Assume the project is Laravel 4 App)
> Checking the provided DB user and pass if they are correct, if yes migrating the DB, if No redirect back with an error.
> Display the 'installation success' page if everything is OK.
I am aware that some activities may require admin privilege and I have it. The web server behind all domains is Apache. I have never done this kind of thing before and so I have no Idea where to get started. Any link or detailed explanations will be fine for now.

Checkout the project Laravel Web Installer its a step towards what you want, it will allow a user to do all the configuration from a web interface.
It also can also handle checking for server requirements, checking folder permissions, migrate the database and seed tables.

Related

How to get running on a local dev environment from an existing and complex Magento2 project

At work we took back our existing store running on Magento 2 from an external development agency. I need to get the project running in local development (with docker).
I familiarized myself with a vanilla project from the official docs and managed to get it running by downloading the vanilla template with composer, granting the proper permissions on files and folder and running the magento setup:install command.
My question is how do one goes when kick starting from an existing (production running) project?
Do I need to run setup:install again? If I do, why?
What do I need to import from production to ensure any content or configuration created via the admin is also running on my local setup? Should I import the complete Database from production?
I know our setup is using more than just php and mysql, but env.php seems to be listing only db configuration and admin url. Where can I get the complete service configuration informations about what our setup uses?
Anything else I am missing to get started with an existing project for local development?
As someone who is running Magento 2 on a local environment myself, hopefully I can shed some light on this.
If you have a direct copy of the live site, you do not need to run setup:install again.
Ensure you have a copy of the entire Magento 2 site (you can technically ignore the vendor folder, as you can run composer install and it will redownload those files, but that's up to you). Also get a copy of the entire database. Magento 2 is notorious for copying the same data to multiple tables so something could break if you don't have everything.
What do you mean by "service configurations" If you are referring to Magento 2 extensions, that data is saved in the database, not the env.php file. env.php is only for server side configurations, such as the DB information, Caching, and things of that nature. On mine, I use Redis for site Cache, so that would be included in that file as well, as an example.
When you first unpack the site to your local environment, run composer update in the directory. This will ensure you have all the proper files installed. If you are going to run a local dev environment, set the mode to development with the following command: bin/magento deploy:mode:set developer. This will allow you to make changes and to view those changes by just refreshing the page, rather than flushing cache all the time.
All queries are replied correctly by Eric. I am also not sure about "service configurations" you have mentioned here. If this is about third-party extensions/services you can check config.php file for this.

Allow Laravel app to create/modify project files?

I have plans on making a generator GUI, accessible on a route while in development mode. When taking some action in the GUI it will create or update corresponding files in the project folder. This means the web server user need permissions to handle the files.
What is a good way to accomplish that? I have thought of a few approaches but not sure.
After you pull in my package, let the user chmod everything themselves. This might be an issue as these changes will be committed to source control
Add some kind of installer script that you can run with sudo to do 1) for you.
Add a temporary workfolder for the generator where it has full access. Then you set up some symlink thing to the actual project folder so it stays in sync. That way you won't have the Git issues.
I am excited to hear what you think about this.

How to move Symfony2 application from localhost to deployment server (LAMP CentOS)

I have developed a Symfony2 app on my local machine. I access it using PHP's built-in server, via http://localhost:8000/
Question: how do I move this application to my VPS (LAMP CentOS) so that it can be accessed like this:
http://example.com
and is it any different for installing it on:
http://subdomain.example.com
PLEASE if by any chance you can provide a step by step instructions, it will be much appreciated and I'm sure useful to many others too. I'm used to working with stuff where you can simply move files from one place to another, update some config data and it works (Wordpress, coding without frameworks etc.)
The best solution to me is to have your project in a versionning system like git or svn without the vendors dir of course ...
This way, your simply have to do :
1) git clone your project into the prod dir
2) php composer.phar install to install your vendors
2b) create the mysql user with correct login and password according to your parameters.yml
3) php app/console doctrine:database:create to create your database with the credentials you set up in mysql
4) php app/console doctrine:schema:update --force to perform the database tables creation
5) testing the project :)
If you are not using a versionning system just upload your project to your server with an ftp software without the vendors directory ( it will be feeded by step 2) then perform 3rd , 4th and 5th steps !
For the subdomain part of your request you have to creats a subdomain folder on your server ( by using plesk if you have it ) or by manually creating a vhost config to specify the sub domain path. I can t provide you an example right now ( i m writing this from my mobile device and i don t have clear step by step procedure in order to achieve this )
[Install your environment]
So, First you need to install and run an apache Server. Find here the minimum basics to get your application running under Apache2. Then make sure you've PHP5 and MySQL up and running. Otherwise check,
Install and Configure MySQL Database Server
Installing and Configuring PHP
[Deploy your application]
Deploying can be a complex and varied task depending on your setup and
needs - Symfony.com
It's then up to you to choose the right way to deploy your application, you can do it,
Using Basic File Transfer
Using Source Control
Using Build scripts
I would recommend using Capifony which was build on top of Capistrano to adapt it to Symfony applications.
[Post-Deployment Tasks]
Your deployment process should be tailored to guarantee that all the required post-deployment tasks (Like updating your dependencies, setting your application configuration files, clearing the cache and dumping your assets, etc) are executed.
To get the big picture, read the How to deploy a Symfony2 application of the Cookbook.

CakePHP Update button

I'm building a CakePHP-application that people can install on their hosting.
In the meantime I'm still working on the application, so I want people to be able to update it just by clicking on an update button.
From the moment I write new code in a Controller, make new Components,..., I push it up to the "Source-server" and they click on update then they have to have all this updated code on their server as well.
I was thinking to write an exec (command line) that executes a git pull/fetch but not every hosting has git installed, so that's not the best solution.
Can somebody help me out with that?
Thanks in advance,
AƤron
You need to implement a package system: Your php script will download a zip file that contains all the code from a source, unpack it in a temporary folder, read the meta data file that tells your script what version the plugin or application code is, compare it with the running version, maybe do some security checks like a checksum or if you like to implement that a signature check. When the checks were successful you'll have to replace the existing files with the files from the package.
You could even give the option to do a rollback if you keep the zip of the previous version. Don't forget that your update code needs a way to fire database migrations as well. I would develop a "Package" or "PluginManager" plugin that does all of that. The event system can be used to trigger events when things are installed / deinstalled.
Wordpress does it this way, you might want to look at what it does but I would not recommend to take any of the fugly wordpress code, just use the concept.
Like joomla , wordpress you can create installation package which can check the current version and check server version.
stept2
after compression it create database and file backup
step3 download pakedge from server under a temp directory
step4 replace new lib with older one
step5 if update successfully then delete pkg from temp directory and delete old file backup
step6 if fail replace the site sitebackup

Symfony 2 without SSH access

I have a developed a small web-app in Symfony 2 and Doctrine 2.
Can i deploy it to a web-host that doesn't give SSH access?
I ask this because i see there are a lot of task that must be done from the terminal, like updating the database schema, creating symlinks for the assets, clearing cache, etc...
Should not be a problem:
Create a copy of the system somewhere, ideally with identical DB connection params like the production system.
Run all the necessary tasks with the --env=prod parameter, if your DB settings allow it.
Clone the created production database to the production system (with phpMyAdmin). You can clone the schema from the production database, run app/console doctrine:schema:update --dump-sql locally and then run the generated SQL on the production server.
Copy all the files, excluding the dirs in app/cache and app/log
I have done this many times with SF 1.4, and it should be just as easy with SF 2.
Some low end hosts have restrictions that will cause issues for symfony, so its important to run the symfony compatibility checker script (you can upload it and then enter its URL in your browser to get the output). Once thats done, follow these simple steps:
copy over all the files for the project. I usually zip/tar the project folder, upload it, and unpack.
Export the database from your development environment and upload it to your new server.
Edit the config and update your database settings. If you have hardcoded paths somewhere in your code, now is the time to fix those as well.
Make sure that the user for apache (or whatever server software your host uses) has full access to the cache and log directories. This can be tricky on some hosts, I have had to contact support in the past to have someone log in and change permissions.
In your web hosts configuration tool, set the webroot for your site to the web folder in your project.
Maybe there is a way (with sftp for example), but it would be like trying to ride a bike with square wheels ;)

Categories