Wordpress and laravel [closed]

1

I have an ecommerce made in wordpress and also for that same website I would like to create a blog. But this blog would like to create it with laravel and the structure of this blog would like to save it in the same wordpress file structure, could I do this procedure? If so, what would be the steps to follow to be able to carry it out?

    
asked by Henry Manuel 08.08.2018 в 23:13
source

1 answer

-1

1 - Wordpress does not process what comes in the url if it is a file or folder on the server, this means that if you create a folder called "blog" in the wordpress root, the server will serve that folder without that goes through wordpress.

2 - Laravel has a "public" folder that is a bootstrap of the application, the require and require_once handles them through the directory structure eg: $app = require_once __DIR__.'/../bootstrap/app.php'; .

So a possible structure is more or less the following:

Assuming wordpress is in the default folder of apache2 (ubuntu)

/var/www/html    -> raiz del wordpress
├── wp-admin
├── wp-content
├── wp-includes
├── .htaccess    -> .htaccess del wordpress
└── index.php    -> bootstrap del wordpress

link < - wordpress homepage

And assuming you do not have any page / post with slug blog

link - > would give 404 error and / or redirection to the wordpress home (depending on the theme)

Then the laravel app is in another folder (example running the tutorial /home/code/$ composer create-project --prefer-dist laravel/laravel blog )

/home/code/blog/
├── app
├── artisan
├── bootstrap
├── composer.json
├── composer.lock
├── config
├── database
├── package.json
├── phpunit.xml
├── public             -> raiz de la app laravel
│   ├── css
│   │   └── app.css
│   ├── favicon.ico
│   ├── .htaccess      -> .htaccess de laravel
│   ├── index.php      -> bootstrap de laravel
│   ├── js
│   │   └── app.js
│   ├── robots.txt
│   └── web.config
├── readme.md
├── resources
├── routes
├── server.php
├── storage
├── tests
└── webpack.mix.js

The way to "create" the folder blog within /var/www/html and that this is the public of the laravel (without having to copy files and make a salad) is through a Symbolic link or symlink

This from console is done like this:

$ ln -s /home/code/blog/public /var/www/html/blog

Now if you go to the corresponding url

link < - laravel homepage

In this case I have the app laravel inside /home/code/ because apache / php need read permissions in the parent folders and not to make permission salad, we declare to /home/code/ in the apache group that can be www-data (ubuntu / debian) or apache (red-hat / centos).

It could be in another folder but there you have to play a bit with the permissions and owner / group.

If it is shared hosting or without SSH access (console), you have to start configuring Laravel in order to rename "public" to "blog" and to raise the app from an extra folder, outside the public_html preferably and if not it's possible to arm yourself with a .htaccess.

If the server allows you, you can also create the symlink with PHP .

Keep in mind that if in the wordpress you create a page with slug blog this will not be seen because there is already a "blog" folder.

    
answered by 09.08.2018 в 22:33