Get database from git project - php

I am a beginner in Laravel. For the purpose of studying, I downloaded and installed a sample project from Github. I followed the given steps and installed the project.
However, I don't know how to import the database from the git repository. I have searched for .sql files in the project folder, but none exist.
Does anyone know how to import the database of this project?

You need to run the migrations - in Laravel, you don't import from .sql files, you run migrations.
$ php artisan migrate
For reference, you can find the migration files here.

You can use basic tools built in the mysql console.
1. Use mysqldump command, it will create a dump file of your database.
2. Add the dump file to the repository
3. If you want to install the db to a remote host, in the ssh console you can use mysql -u username dbname -p < dumpfile.dump (or .sql). You can do this on your localhost too from xampp shelp/terminal/cmd
4. Enter your password

Related

How can I organize my laravel project's github repository so that users can easily install and run it?

Five months ago I created a pretty extensive Laravel Blog Management system. I am now at a point where I am looking for a job and would like for potential employers to be able to easily install and run my project to check it out. I want to include instructions in the readme.md on how to get it started but I've just realized that I can't figure out how to run it myself!
Here is the repository: https://github.com/colesam/Laravel-Blog
Here is what I've tried:
git clone git#github.com:colesam/Laravel-Blog.git
composer install
php artisan serve
This copied the repo into my xampp/htdocs directory and ran it. XAMPP is currently running with MySQL and Apache running.
The console responds by telling me it's being served on localhost:8000. Unfortunately I receive an error message on the actual html doc:
What is going wrong with my project and how can I make this as easy as possible for my potential employers / anyone who would like to download and check out my project?
It's really easy actually. Takes about ~5 minutes. Here are the steps:
Clone the project
Create a database
Copy .env.example to .env and set the correct database credentials
Run php artisan key:generate to generate the app key
Run php artisan migrate to create the tables
Run php artisan serve
And you're done.

Mysql not found even the Laravel-homestead is installed

I am a newbie to both Laravel and PHP. Now I wish to link my Laravel project to Mysql database. I am using the os x 10.10 and I have already installed homestead and vagrant. But when I input which mysql in the command line, it is told that mysql not found.
A mysql database is supposed to be included in the homestead package. But why can't the mysql be found? How can I link my project to mysql db and how can I ensure that I have successfully done that? Thanks in advance!
If I guess correctly you are trying to find mysql on your physical machine, when it is actually installed on your virtual machine. You have to connect to the Homestead via ssh first, in order to do which mysql. So in your terminal do:
homestead up
homestead ssh
which mysql
You can read more about Homestead in the documentation documentation. Also you can read wiki article to keep up with concept of virtual machine.
To create a new database inside the Homestead you simply have to find you Homestead.yaml file (usually path is ~/.homestead/Homestead.yaml) and add the name of you database to the databases section:
databases:
- homestead
- your_new_database_name
Then you have to provision the Homestead machine with homestead provision. After this the databases will be created and only thing you will have to do is link to it from you projects .env file (located in the root of your Laravel project):
DB_HOST=localhost
DB_DATABASE=your_new_database_name
DB_USERNAME=homestead
DB_PASSWORD=secret
This have to do it. The Laravels documentation regarding database is really great. Usually you can find all you need there. I guess you will need to create some migrations to create the schema for you databases. It is covered there too.

Illuminate Database outside Laravel with Phinx for migrations

I'm working on a project where I'm using Illuminate's database component outside of Laravel 4.2 and trying to use Phinx for migrations from the command line. I've set up my database environments in the phinx.yml file for production, development, and my local, which I named "vagrant". When I try to run the "php vendor/bin/phinx migrate -e vagrant" it comes backs saying "Could not determine database name! Please specify a database name in your config file." I've tried multiple times to figure out what's causing it, the database name is correct. Any ideas?
Thanks!

Laravel 5 - How to create queue table with Command Prompt in Windows 8.1

I am using Laravel 5 on my local with Windows 8.1. I successfully installed laravel with windows, it was hard because laravel's official documentation never talk about windows. However, I want to add a new table in my Database using Artisan Command. As you can already guess, it's not working on PC. I open command prompt as administrator and type this :
php artisan queue:table
This is probably working on a Mac or Linux but not on Windows...is there any artisan command to do the exact same thing but for PC?
I actually just need to create this table and I can't find anywhere the structure of this table. Thx!
Step 1
You have to have PHP installed and be able to run in from the command prompt. Test that by typing:
php -v
If you get a version number and some other details proceed with Step 2, otherwise follow this tutorial on sitepoint at least until point 4. The most important part being the adding of your PHP directory (where php.exe is located to the PATH system variable). After doing that, make sure to re-open CMD.
Step 2
Artisan is actually just a normal PHP file with no extension. You have to be in your project directory to run it. Make sure that's the case.
> cd C:\Path\To\Laravel\Project
> php artisan queue:table
Step 3
If you get some kind of error from php artisan * the next step mostly depends on that error. If it can't connect to the DB for example, you should first make sure that the credentials are configured correctly. If you have an error you don't understand, look it up online and if that doesn't help, post it along with your question.

Symfony2 app/console on a project copy

I have a Symfony2 project setup in /var/www.
Because I want different users working on the same project, I copied this project to their directory and changed the name of the database for example. I did that so they can test their changes on the server rather than installing wamp locally on their machine. Those changes will then be committed via svn/git.
However, the problem I am facing now is:
Because I copied the Symfony2 project to their own directory (e.g. home\mike), the user or I can not execute a php app/console command, because it is still refering to the one in /var/www.
So for example, when I do:
sudo php app/console doctrine:schema:update --force
This command will be executed on /var/www/Symfony rather than on home\mike\Symfony
How can I refer it to his own directory?
Thank you.
At first, try to manually clear cache in your new project path.
Then, check this article, about migrating project: How to override Symfony's Default Directory Structure
Each project has it is own structure and the command.
If you have symfony on www you must have the console file under app

Categories