PHP local setup / only ever coded live - php

I've only ever coded to a live web server (well using a test domain and then transferring to the live one).
I actually know a decent amount of PHP, just never coded locally.
I want to also set up, learn and use Symfony2.
I also want access to the command line (as I know Symfony 2 requires this to set up bundles etc.)
I also know people integrate this with Github.
I'm using a Mac OS X 10.8.2.
I want to use Apache as the web server.
I understand everybody codes 'locally'. How do I set all this up? Maybe just a list of all the things I need. This is my rough understanding so far:
(1) Get http://www.mamp.info/en/index.html
(2) Get Composer (not sure what for though)
(3) Symfony2 download
What about command line access though?

Here a bit more info:
Installing Composer locally.
1) edit or create ~/.bash_profile
2) add this to edit (change to correct php version):
alias phpmamp='/Applications/MAMP/bin/php/php5.3.6/bin/php'
3) Refresh terminal bash:
. .bash_profile
4) Install Composer using:
curl -s https://getcomposer.org/installer | phpmamp
phpmamp is your PHP installed by MAMP

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.

PhpDocumentor for Laravel 5.7/6.x

This might be a very newbie question but, how exactly do you use phpDocumentor to generate your docs through Laravel? In my Laravel project there's no phpdoc in the vendor/bin directory, and trying to install phpDocumentor via composer fails (as suggested on the GitHub page).
I couldn't find any recent resources about it, the only thing I had luck with is running the phpDocumentor.phar file from the terminal, but the newest version fails immediately.
To get this working, downgrade to PHP 7.1. Then download the latest phpDocumentor.phar file from [http://www.phpdoc.org/phpDocumentor.phar]. Place the phpDocumentor.phar into your Laravel 6.x project's /vendor/bin/ directory.
Then use Homebrew to install other needed packages...
brew install intltool
brew install graphviz
Lastly, cd into /vendor/bin and run...
php phpDocumentor.phar -d ../../app/Http/Controllers
Your documentation output should be at /vendor/bin/output.
Adding a more complete solution that worked for me on creating documentation of my Laravel project with the system environment comprising of MacOS Catalina,Laravel 6 and PHP 7.2.
Visit https://docs.phpdoc.org/3.0/guide/getting-started/installing.html. To install the dependencies, recommended to update homebrew as brew update and brew upgrade. After updating the homebrew, execute the following:
brew install graphviz
brew install plantuml
Once the dependencies are installed, download the phpDocumentor.phar from the above link, and make the file executable as follows:
chmod +x phpDocumentor.phar
Then, copy and paste this file to your laravel app under /vendor/bin
I also placed this file under local bin mv phpDocumentor.phar /usr/local/bin/phpDocumentor for easier access (as shown in step 6 below).
For testing purpose, create a simple test.php file under /vendor/bin/docs/test.php directory with the following content as mentioned in https://docs.phpdoc.org/3.0/guide/getting-started/your-first-set-of-documentation.html
<?php
/**
* This is a DocBlock.
*/
function associatedFunction()
{
}
Then execute the phpdoc script from the same /vendor/bin location as:
phpDocumentor.phar -d docs/test.php -t docs/test
This will generate several files.
Open the index.html file generated in your web browser (eg. Chrome) to view the documentation:
open -a "Google Chrome" ./docs/test/index.html
Notably, because we placed the phpDocumentor.phar in /usr/local/bin/phpDocumentor/phpDocumentor.phar, we can easily access phpdoc and easily create the documentation of our whole App as follows ( the documentation will be stored inside the folder DOCS)
phpDocumentor.phar -d app/ -t DOCS/
I have found the problem with most PHP documentation solutions is they require large amounts of code just to get something you can actually use. And that takes a lot of time and trial and error to set up.
I also have issues with the generated documentation. Often it is not even sorted! Also it is hard to navigate and understand the whole class. As a consumer of a class, you are not interested in private or even protected things (unless you are trying to extend it). But often the docs only show you the methods and properties of the current class, and not what it inherits (which is the WHOLE point of OO!).
Anyway, I got sick of the current state of PHP documentation and decided to do it right. I wrote PHPFUI/InstaDoc to address all the issues I had with existing solutions. InstaDoc is the fastest document generator out there because it simply scans the class directory structure and saves it off. This generally only takes a few seconds (for large code bases) each time you generate (on release, or if you add a new class in your dev env). Then it renders the docs for a specific class at runtime, because, hey, who ever looks at the documentation anyway? Just us nerds, and there are not many of us, and we can wait a fraction of a second for the server to generate the docs on the fly. Also you don't need server disk space to store all your docs. They are generated on the fly. And of course if you have a high volume site, InstaDoc can generate static HTML files, but who has a high volume PHP doc site (like nobody).
Anyway, check out a live example at PHPFUI/InstaDoc and see if it fits your needs. It is not a Laravel module or plug in, but you should be able to run it under Laravel easily. Just return the output of the controller in your controller, and it should just work.

My laravel project start page is not opening

I have install Laravel in my pc using composer.
I used gitbash and started xampp control server
First I've changed my directory.
Then I've ran a command composer create-project laravel/laravel project_1. After the command had run, it installed laravel and all necessary file and key was successfully set.
Then I again changed my directory to project_1
Then I ran another command php artisan serve. After running this command Laravel development server started and 127.0.0.1:8000 this ip has genrated.
I copied the id and paste it in my browser url bar.(I copied and pasted it without using keyboard. I only used mouse)
but when I provided the ip the project_1 starting page did not open.
The page was loading and it is still loading.
what can I do? Please help
logs folder
Here is my contribution, I cannot say what is the cause but I have a solution for it; because I have such as a challenge.
run
php -S 127.0.0.1:8000 -t public
Note that the 8000 is your port, and this could be any 4-digit number.
I hope this helps
Every thing you did seems right to me in terms of Laravel requirements, so lets check some other possible issues:
make sure that your internet connection isn't configured to use
proxy, if so make sure you excluded your local address.
if you are using Internet security suite software, make sure it doesn't block your requests, this vary from software to another but you might test this by deactivating the software for a while until you try.
now that's what I have in mind, I hope it help.
First, stop the php artisan serve
After changing directory go to inside your project folder, you can run php artisan serve. Then a localhost URL will be generated for you where you can see your project in the browser
If you have PHP installed locally and you would like to use PHP's built-in development server will start a development server at http://localhost:8000
Please try to install Laragon and forget about Xampp for now. This is really cool tool and you'll start much quicker. I did try to resolve few issues with Xampp myself and always wasted a lot of time. You can google tutorials later for it as well. Plenty of info out there.
As well it comes with in house installer for Laravel ;) and more :).
Make sure that you are not coping the url from Git Bash through command, it will stop running the project
Make sure that you are not using antivirus specially avast antivirus.

gcloud, where's the code? How can I update the deployed code manually?

I deployed a local project using gcloud command since there everything OK. I'm getting a 500 error in the browser, but I still have hundreds of questions. Where's the code? What is doing gcloud behind the scenes when I do a deploy? Why do I see 3 instances when I just deployed just one project?
I did SSH to each of the three compute instances I see and I couldn't find the code. I want to do something very silly and easy, just go to the index.php file and do echo '1';die; to check that's the code I can play with to make my project work on Google Platform.
Because I'm noob on this I won't be able to tweak my project perfectly to work on Google Cloud at first, so it's probably silly but a must!
My current and only config file:
runtime: php
vm: true
runtime_config:
document_root: public
You are using the AppEngine Flexible Environment (what used to be called Managed VMs). This environment uses Docker to build an image out of your application code and run it in a container.
See the Additional Debugging part of the Managed VMs PHP tutorial for more info on how to debug on the machine. After SSHing into an instance, you are on the host machine, but you still need to run additional commands to access the container, which is where your application code is running. The following command will get you on your machine:
sudo docker exec -t -i gaeapp /bin/bash
Once there, you can edit your running application by running the following commands
apt-get update
apt-get install vim # or your editor of choice
vi /app/public/index.php # I am assuming this is where your file is
Yes, you have to install vim on the container because it will not be installed by default, as this is your production image.
Also be sure to check the Logging page in Developer Console, as that is where the 500 error message will be logged, and it's a lot easier than going through these steps!

Magento - using "mage" command line tool locally

I currently have Magento set up on a development server (remote, SSH access) and production server (Cloud instance, SSH access). The current set up is a subversion export to update the development/production servers. This works swell.
If I SSH into the dev server, I can navigate to the Mage root directory and run the following command:
./mage install community Namespace_Module
This works well on the dev server. However, when I navigate to my local path (on my machine, where I've svn co'd Magento), running the mage tool always chokes when a channel is involved. As an example, I tried:
./mage download community Namespace_Module
And received the following response:
Error:
download: Uri doesn't contain host part
I don't understand why this error occurs. I have looked into the mage tool's code and found that the error occurs when the channel URL is malformed. (The mage tool is basically a PHP script, and it uses parse_url to separate the channel URL into the appropriate parts for processing.) However, I am absolutely certain that the setup is identical locally, as it's all in svn, and I have tried many iterations of channels in an attempt to make it work locally.
The ultimate goal of all of this is to be able to run the ./mage tool to install modules on the local system, and commit them to svn from there. Ideally, running an svn status command should show me all the files that would be added/modified during the installation of the module.
Anyone have any ideas as to why this might be happening and how to make it run locally? Thanks!
UPDATE
For anyone wondering, the way I handled this was using the old pear command line tool, then running svn status to extract the downloaded package pieces into the way our systems are organized. It's definitely not ideal and I am still eagerly hoping to get an answer to my original question, but it's the ugly and painful workaround I'm using in the interim.
You should check whether you have all necessary php extentions installed localy.
Missing php5-curl might be the problem.
As you have gotten the code from another server, you might need to reinit things using:
./mage mage-setup
You could also try:
./mage channel-add http://connect20.magentocommerce.com/community

Categories