Laravel vs. Django Running a Project - django

I have a Laravel project. I would like to know how can I run it and view the pages on my browser? Like for example, if I had a Django project, I would simply cd to it and type "python manage.py runserver" in the terminal to run the project. How can I do this with a Laravel Project?

Use the artisan serve command:
php artisan serve

I like the bare php command more, it provides some nice colors, green for OK, red for errors.
php -S localhost:8000 -t public/
Or even:
echo "php -S localhost:8000 -t public/" > start_server.sh
sh start_server.sh

Depends on your operating system (OSX, Windows, Linux) but I find that the software Laragon https://laragon.org is very good in providing everything you need, including apache, mysql, editing the host file, and sending (test) emails.

Related

Can't activate django python environment in docker django application

Can't understand django command in docker application.
I am trying to run command which normally would work.
source project/bin/activate
Which results in :
-bash: project/bin/activate: No such file or directory
The command would work in non docker django app for sure. Also tried :
docker-compose run web source project/bin/activate
docker-compose up source project/bin/activate
What is right command then?
Have you tried, giving absolute path for the activate file. Something like this:
~/workspace/project/bin/activate
The above might actually work.

jenkins start django server after successful build

We use jenkins as continious integration system. We have two django servers validated by jenkins.
jenkins validates successully the first server. The second server depends on the first one. Thus we would like to launch at the end of the first server validation the first server itself.
We are using python, virtualenv and django and defined the Virtualenv Builder as follow:
pip install -r requirements.txt
rm -f .coverage
fab localhost test
coverage xml
nohup python manage.py runserver 9090 &
The issue is that the build never ends due to the nohup.
How can I launch the server after a successful build?
I had the same problem.
Ken,
I tried using fabric, but again python manage.py runserver - runs continuosly, so the next command is not starting.
And just few mins ago my collegue showed me how to use nohup and with variable BUILD_ID of Jenkins it would be like this to get Success from the build and leave the Django server running:
BUILD_ID=dontKillMe nohup python manage.py runserver host_server &
This worked for our Django project testing.
Since you are using fabric to test, I would recommend defining another fabric task, say, deploy, which you could call assuming the build succeeds.
Much like the call to fab completes for a successful build such that you get to the nohup line, I would expect the deploy task to return also.
You may also want to consider making the server a service (either via an /etc/init.d style script, or upstart if Ubuntu), and have the fabric task stop the currently running one, copy over whatever new files it needs (or similar process), and then restart it.
Assuming what you have above is a bash script or similar, you may want to also define set -e so that, in case any of the commands returns a non-success code, the script will fail, and in turn, fail the build.

Django 1.2 - Management - Command - Can't Run manage.py commands on crontab

On my project i have an app : my_app with Managment command : my_command.py
On SSH i try :
my/folder/project/and/app/python2.4 manage.py my_command all is ok
but if i try : python2.4 /my/folder/project/and/app/manage.py my_command, manage.py doesn't know my command...
i try to run my command on a crontab..
Thx
laurent
In my experience I had this kind of issues for several reasons.
I'd check first the python interpreter used. If you are using virtualenv or something like that you should ensure you are using the correct python executable.
If your server has selinux, you should ensure it's not denying the cron to read some files.
I also had an issue like this because the settings file (I used a separate setting file to make it less verbose) didn't exist.

heroku buildpack for python/geos

I am running my django app on heroku. I want to use their websolr plugin to add spatial search to the app via django haystack.
Spatial serach in django haystack depends on the GEOS C library that is not deployed on heroku by default.
So in order to use spatial search I followed https://devcenter.heroku.com/articles/buildpack-binaries to create a binary package of GEOS.
To deploy the binaries I forked the heroku buildback for python and modified bin/compile to include:
AWESOME_VM_BINARY="http://vulcan-dtornow.herokuapp.com/output/05391114-f314-4aa7-9aab-bc09025d4898"
mkdir -p /app/.heroku/vendor/geos
curl $AWESOME_VM_BINARY -o - | tar -xz -C /app/.heroku/vendor/geos -f -
I added the custom build pack to my application, redeployed but still I cannot access the library. When I run ls the geos folder does not show up
heroku run ls /app/.heroku/vendor
Any idea what I am missing? Thanks for your help!
Another option is using a buildpack that only contains the geospatial libraries and combine it with the python buildpack. This is a cleaner separation:
https://github.com/cyberdelia/heroku-geo-buildpack/
in combination with
https://github.com/heroku/heroku-buildpack-multi
To use it add a .buildpacks file to your repo that looks something like this
https://github.com/cyberdelia/heroku-geo-buildpack.git
https://github.com/heroku/heroku-buildpack-python.git
(the use of multi buildpacks is explained in the multi buildpack repo as well)
You should be able to use the GeoDjango buildpack that was already created here

Django management task won't work on CentOS in crontab or outside project directory

On my local machine (Mac OSX 10.6) I wrote a django custom admin command which works great. I can use it both within and outside my project directory just fine. For some reason on my CentOS 5.6 server, it won't work from outside the project directory. This is really annoying since using this custom admin command in a cron job requires it to run from the home directory.
in short:
When I run "python ./manage.py scrape" or "python manage.py scrape", everything is fine.
When I run "python /home/[username]/webapps/myproject/manage.py scrape" or "python myproject/manage.py scrape", I get the following error:
unknown command: 'scrape'
Type 'manage.py help' for usage.
On CentOS, when I run manage.py help inside the project directory, scrape shows up as a command; but if I run it outside the project directory, scrape does not appear as a valid command. On OS-X scrape appears as a valid command regardless of where I run manage.py help from.
Any idea how I can fix this?
I know CentOS ships with Python 2.4, so is your code running on 2.4 or are you using a contained environment, this is usually fixed by adding your PYTHONPATH correctly
import sys
print sys.path
verify such for starters
This should get you up and running: http://djangosnippets.org/snippets/374/