Laravel: Difference between revisions

No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
One of the best parts of Laravel is their excellent video course on web development.
One of the best parts of Laravel is their excellent video course on web development.
The course is published on Laracasts.
The course is published on Laracasts.
<!-- Why use Laravel?
* Security - [https://auth0.com/blog/why-laravel-is-the-recommended-framework-for-secure-mission-critical-applications/ auth0 blog]
* Authentication - [https://laravel.com/docs/master/authentication Authentication Docs]
* Eloquent ORM (Object relational mapping) - [https://laravel.com/docs/master/eloquent Eloquent Docs] -->


==Usage==
==Usage==
Line 120: Line 115:
==Deployment==
==Deployment==
===Directly===
===Directly===
Point your webserver with PHP to the public folder
Point your webserver with PHP to the public folder.<br>
 
If your application is publically accessible, make sure APP_DEBUG is set to false.
===Heroku===
[https://devcenter.heroku.com/articles/getting-started-with-laravel Laravel on Heroku] 
[https://appdividend.com/2018/04/17/how-to-deploy-laravel-project-on-heroku/ Deploy Laravel on Heroku]
 
# Run <code>heroku create</code>.
# Configure everything.
#* Set <code>heroku config:set LOG_CHANNEL=errorlog</code>
# Create a Procfile and commit it to your git repo.
# Push to heroku with <code>git push heroku master --no-verify</code>
# Open with <code>heroku open</code>
 
;Notes
* Make sure you are using the <code>heroku/php</code> buildpack.


===Docker===
See the example Dockerfile below:
<syntaxhighlight lang="Dockerfile">
# Dockerfile
FROM php:8.1-apache
RUN apt-get update && \
    apt-get install -y nodejs npm zip libpq-dev sudo && \
    a2enmod rewrite
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/apache2.conf
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# RUN sed -i 's#upload_max_filesize = 2M#upload_max_filesize = 200M#' "$PHP_INI_DIR/php.ini"
# RUN sed -i 's#post_max_size = 8M#post_max_size = 200M#' "$PHP_INI_DIR/php.ini"
RUN chown www-data:www-data /var/www -R
ADD package.json package-lock.json /var/www/html/
RUN sudo -u www-data npm ci
ADD composer.json composer.lock artisan /var/www/html/
ADD app /var/www/html/app
ADD config /var/www/html/config
ADD database /var/www/html/database
ADD bootstrap /var/www/html/bootstrap
ADD routes /var/www/html/routes
RUN composer install
# Add remaining files
ADD . /var/www/html/
RUN cp .env.prod.example .env
RUN chmod 775 /root && \
    chown www-data:www-data -R /var/www/html && \
    npm run prod
</syntaxhighlight>


==Security==
==Security==