├── LICENSE ├── README.md ├── natal.php ├── sweph ├── index.html ├── seas_12.se1 ├── seas_18.se1 ├── semo_12.se1 ├── semo_18.se1 ├── sepl_12.se1 ├── sepl_18.se1 └── swetest └── transit.php /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mukesh Chapagain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP Swiss Ephemeris 2 | ======== 3 | Getting Planets Position using PHP & [AstroDienst Swiss Ephemeris](http://www.astro.com/swisseph/) library. 4 | 5 | About Swiss Ephemeris 6 | ------------- 7 | The SWISS EPHEMERIS is the high precision ephemeris developed by Astrodienst, largely based upon the DExxx ephemerides from [NASA's JPL](http://en.wikipedia.org/wiki/Jet_Propulsion_Laboratory_Development_Ephemeris). 8 | 9 | You can download the Swiss Ephemeris library from the following links: 10 | 11 | [http://www.astro.com/ftp/swisseph](http://www.astro.com/ftp/swisseph) OR [ftp://ftp.astro.com/pub/swisseph](ftp://ftp.astro.com/pub/swisseph) 12 | 13 | In this repository, I have included following two time range's files. 14 | 15 | Planetary file | Moon file | Main asteroid file | Time range 16 | -------- | --- | --- | --- 17 | sepl_12.se1 | semo_12.se1 | seas_12.se1 | 1200 AD – 1799 AD 18 | sepl_18.se1 | semo_18.se1 | seas_18.se1 | 1800 AD – 2399 AD 19 | 20 | Time range from 1200 AD to 2399 AD is enough for general astrological calculation. 21 | 22 | Name of library files associated with different time ranges is given in this detailed [**Swiss Ephemeris doc**](http://www.astro.com/ftp/swisseph/doc/swisseph.pdf). 23 | 24 | You can download the library files for other time ranges from download area: 25 | [http://www.astro.com/ftp/swisseph/ephe/](http://www.astro.com/ftp/swisseph/ephe/) OR [ftp://ftp.astro.com/pub/swisseph/ephe/](ftp://ftp.astro.com/pub/swisseph/ephe/). [*Note: Scroll down the list and you will see the files to download.*] 26 | 27 | Code & Output 28 | ------------- 29 | This code has been tested on Ubuntu Linux Machine. 30 | 31 | There are two files at the moment. 32 | 33 | **1. transit.php :** Outputs current planetary positions 34 | 35 | **2. natal.php :** Outputs planetary positions and ascendant degree for any particular date (e.g. birth date) 36 | 37 | Here's a line of code from *transit.php* which is responsible for outputting current planetary positions: 38 | 39 | ``` 40 | exec ("swetest -edir$libPath -b$date -ut$time -p0123456789mt -n1 -sid1 -eswe -fPls -g, -head", $output_s); 41 | 42 | var_dump($output_s); 43 | ``` 44 | 45 | In the above code, you can see different command line options. You can get details about them from here: 46 | https://www.astro.com/cgi/swetest.cgi?arg=-h&p=0 47 | 48 | In the output array elements: 49 | 50 | - First part is Planet Name 51 | - Second part is Planet Degree 52 | - Third part is Planet Speed per day 53 | 54 | The output of the above code will be like below: 55 | 56 | ``` 57 | array (size=12) 58 | 0 => string 'Sun , 113.3930700, 0.9587323' (length=40) 59 | 1 => string 'Moon , 318.8409756, 12.9537458' (length=40) 60 | 2 => string 'Mercury , 137.1164786, 0.2663238' (length=40) 61 | 3 => string 'Venus , 76.6969846, 1.1684473' (length=39) 62 | 4 => string 'Mars , 109.0169143, 0.6400332' (length=40) 63 | 5 => string 'Jupiter , 174.1758557, 0.1512867' (length=40) 64 | 6 => string 'Saturn , 237.2760952, -0.0246188' (length=40) 65 | 7 => string 'Uranus , 4.4071387, -0.0054264' (length=39) 66 | 8 => string 'Neptune , 319.4429069, -0.0239242' (length=40) 67 | 9 => string 'Pluto , 263.3135899, -0.0204321' (length=40) 68 | 10 => string 'mean Node , 120.4265476, -0.0529537' (length=40) 69 | 11 => string 'true Node , 120.0887980, 0.0073022' (length=40) 70 | ``` 71 | 72 | Thanks 73 | ------------- 74 | Allen Edwall for [PHP Scripts for Astrological Websites](http://www.astrowin.org/php_scripts/index.html) 75 | 76 | **#Astrology** **#Astronomy** 77 | -------------------------------------------------------------------------------- /natal.php: -------------------------------------------------------------------------------- 1 | format('Y-m-d H:i:s'); echo '
'; 14 | 15 | /** 16 | * Latitude Longitude 17 | * of Kathmandu, Nepal 18 | */ 19 | $latitude = 27.7172453; 20 | $longitude = 85.3239605; 21 | 22 | /** 23 | * Timezone value for Nepal 24 | * As Nepal time is 5 hours 45 minutes ahead of UTC 25 | * 26 | * Put this value according to your country 27 | */ 28 | $timezone = 5.75; 29 | 30 | /** 31 | * Converting birth date/time to UTC 32 | */ 33 | $offset = $timezone * (60 * 60); 34 | $birthTimestamp = strtotime($birthDate->format('Y-m-d H:i:s')); 35 | $utcTimestamp = $birthTimestamp - $offset; 36 | //echo date('Y-m-d H:i:s', $utcTimestamp); echo '
'; 37 | 38 | $date = date('d.m.Y', $utcTimestamp); 39 | $time = date('H:i:s', $utcTimestamp); 40 | 41 | $h_sys = 'P'; 42 | 43 | // More about command line options: https://www.astro.com/cgi/swetest.cgi?arg=-h&p=0 44 | exec ("swetest -edir$libPath -b$date -ut$time -p0123456789DAmt -sid1 -eswe -house$longitude,$latitude,$h_sys -fPls -g, -head", $output); 45 | 46 | 47 | # OUTPUT ARRAY 48 | # Planet Name, Planet Degree, Planet Speed per day 49 | var_dump($output); 50 | 51 | ?> -------------------------------------------------------------------------------- /sweph/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sweph/seas_12.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/seas_12.se1 -------------------------------------------------------------------------------- /sweph/seas_18.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/seas_18.se1 -------------------------------------------------------------------------------- /sweph/semo_12.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/semo_12.se1 -------------------------------------------------------------------------------- /sweph/semo_18.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/semo_18.se1 -------------------------------------------------------------------------------- /sweph/sepl_12.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/sepl_12.se1 -------------------------------------------------------------------------------- /sweph/sepl_18.se1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/sepl_18.se1 -------------------------------------------------------------------------------- /sweph/swetest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/php-swiss-ephemeris/f0a39b8a170dfbc149ba54763c0f2ec0e4613810/sweph/swetest -------------------------------------------------------------------------------- /transit.php: -------------------------------------------------------------------------------- 1 | format('d.m.Y'); 14 | $time = $currentDate->format('H:i:s'); 15 | 16 | # OUTPUT ARRAY 17 | # Planet Name, Planet Degree, Planet Speed per day 18 | 19 | // More about command line options: https://www.astro.com/cgi/swetest.cgi?arg=-h&p=0 20 | 21 | // TROPICAL ZODIAC 22 | exec ("swetest -edir$libPath -b$date -ut$time -p0123456789mt -eswe -fPls -g, -head", $output_t); 23 | var_dump($output_t); 24 | 25 | // SIDEREAL ZODIAC using Lahiri Ayanamsa | Planetary position for single day 26 | exec ("swetest -edir$libPath -b$date -ut$time -p0123456789mt -n1 -sid1 -eswe -fPls -g, -head", $output_s); 27 | var_dump($output_s); 28 | 29 | // SIDERAL ZODIAC using Lahiri Ayanamsa | Planetary position for 5 consecutive days 30 | exec ("swetest -edir$libPath -b$date -ut$time -p0123456789mt -n5 -sid1 -eswe -fPls -g, -head", $output_s5); 31 | var_dump($output_s5); 32 | 33 | ?> --------------------------------------------------------------------------------