Laravel different environment git .env Xampp & Mamp - php

i'm using github in combination with laraval for the first time.
I have 2 local environments :
a) i use MAMP Pro for local development (Mac)
b) i use XAMPP for local development (Windows)
I made a new repository and pushed to github on environment a) , I cloned this repository on setup b) and added a .env file to setup my database. However i'm a bit confused what to do with the app_key value, do i need to just copy it form my initial environment? or need a new one?.
The second part of my question is that i seem to have problems with xampp vs mamp pro because they rewrite a couple of urls, wich means my project won't run on environment b). Are there other settings i need to adjust? and will it brake again if i commit on environment b) ?
Error message when running the project on environment b)
Warning: require(D:\dev.local\ADifferentDesign\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in D:\dev.local\ADifferentDesign\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'D:\dev.local\ADifferentDesign\bootstrap/../vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in D:\dev.local\ADifferentDesign\bootstrap\autoload.p
I'm really confused , i saw other questions like this but none are quite what i was looking for.
A good aproach for future projects would also be very much appreciated
Progress update 1: I updated my .env file with the same key. But the error shown above still persists. I dont want to change te path in autoload every time i switch environments either.

It depends. If you are sharing any resources that hold encrypted data between the two environments, like a database, then you must copy the app_key. This is because Laravel uses the app_key whenever it encrypts something like a user's password or a session ID.
If you don't need to share a database, sessions, etc then you can and should generate a new key for every environment.
You generate a new key by running this command in your site root:
php artisan key:generate
Ideally, you would run this command as the first step in setting up a new environment, before running database seeds or other stuff. This is because if you generate a new key after seeding your database then any password you created in the seeds will be invalid and you'll have to reseed the database.

Related

Is it possible to change cached Container folder name?

I am currently working on the project that has over 20 cron jobs. Some of them are pretty long processes. It was built on Symfony 2.8, so we decided to upgrade it to 3.4 LTS.
After the upgrade we noticed that, if there is ongoing cron job (long process) and we push some changes to Prod environment we get this error:
Fatal Compile Error: require(): Failed opening required '/.../cache/prod/
Turns out, that when we deploy the changes, cached container (in var/cache/prod/ContainerXXXXXX) changed the XXXXXX value. Or in other words, we clear the cache (during deploy) and then it generates new Container in cache directory. More about this problem: https://github.com/symfony/symfony/issues/25654 .
So, my question (and idea) is, is it possible to make cache Container directory name always the same? Maybe any ideas how?

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.

Failing at getting Laravel Running on Windows

I'm trying to get a laravel programming enviroment up to finish my masters' degree project but I can't get this to work no matter how hard I try.
I've followed various tutorials but the last one I've tried has been http://sherriflemings.blogspot.com.es/2015/03/laravel-homestead-on-windows-8.html
and I think I got somewhere but I get the following error trying to initialize vagrant
Vagrant up error:
and I've confirmed that the file C:\Users\Administrator\homestead\Homestead\scripts\homestead.rb is available and permissions are correct.
Also In the error I see C:/Users/Administrator/.ssh/id_rsa (Errno::ENOENT)
but I have other routes difined in my Homestead.yaml
Is there any other way I can run homstead of have a Laravel development enviromet?
What tutorial would you recommend to get this up and running?
You should generate key to make it work. So, you will have two files
id_rsa and id_rsa.pub in your C:/Users/Administrator/.ssh/ folder.
As I totally agree with the previous answer, I wanted to provide some more information about your state.
There is no need to check if the homestead.rb exists at that stage. Because it is already the running code and informing you about the problem that it can't fix by herself.
That is also not a route problem (to tell the truth; the provided information under 'sites' key of Homestead.yaml is not about routes. You are listing the projects inside your homestead virtual machine there. One site per project is generally enough. Like:
-sites:
- map: foo.com
- to: /home/vagrant/Code/Foo/public
Your homestead.rb file is blocked while running because the created virtual machine's operating system needs something to trust your code working using ssh. And one of the ways of achieving that is using a public key - private key pair (also used by homestead). It looks like you don't have a pair. And the script running can't access the public key: AKA id_rsa.

How I can install and configure an existing Laravel Project? (Laravel 4)

I need to install and configure an existing Laravel 4 project.
I tried to do, but when I ran composer update or composer install a lot of issues appear.
I have the database too (with data) so I ran the migration but doesn't work because the console show me an issue about the "table doesn't exist".
Can anyone tell me the complete process to configure the App?.
I mean, what its first, second and so and so because maybe in some step I made a mistake
To install and configure an existing project, you'd typically
Check out its source code
Run composer install
Run php artisan migrate
Check the README for specific instructions on installing 3rd party assets, or any additional steps you'd need to take
If the above creates errors, its either because of something in your environment (installing over an old project?) or some problem with the way the Laravel developer created their project.
To install and configure an existing project, you'd typically check those things first :
You should goto app/config/database.php check file and verify username and password.
After check in Project Folder vendor folder and composer.json file exist then remove it (that remove old configuration now we going to fresh configuration).
Then after back to command prompt and fire command composer update and that download some dependent file download.
Now Run php artisan serve
that tricks work for me last time when I migrate another host.
Carlos, when using an existing DB you'll need to check the migrations table to see which migrations have run successfully. Typically when taking over a laravel project setting up a new db and running the migrations against it is a good idea because you never know what hacks were made to the database outside the migration system. One small change can throw the entire system into a useless state because it's looking for a table or column that doesn't exist or has been modified. If you run the migrations against a bare db you can also figure out which tables were manually created (which could very well be your issue) outside the system and add them in as necessary. Cobbling things together after a previous developer is tedious, hopefully there is decent documentation.
Note that if you are using Git with .gitignore, don't forget to copy .env variables in new location too.

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